Moving crop function out of directive markup to handle it better