scottcheng / cropit

A "customizable crop and zoom" jQuery plugin.
http://scottcheng.github.io/cropit/
MIT License
874 stars 304 forks source link

How to prevent processing in the onFileChange event #63

Closed melat0nin closed 9 years ago

melat0nin commented 9 years ago

Hi all

I'm validating the chosen file using the onFileChange event, but I can't see how to prevent cropping if the file doesn't pass the validation -- returning false makes no difference.

Alternatively, I can validate the file and when it passes fire the $(img).cropit() function, but the image in .cropit-image-preview isn't properly updated.

Any help much appreciated, this is an amazing piece of software :)

scottcheng commented 9 years ago

I'm afraid at the moment there's no way to programmatically prevent the image from loading into the preview box, if that's what you're looking for. It could be a valuable addition though.

On the alternative, I'm not exactly sure what you mean by "fire the $(img).cropit() function", but the image would be ready in onImageLoaded callback. onFileChange is fired as soon as the user selects a file, before the image even begins to load.