Closed rafecolton closed 3 years ago
Updated this to work with ACF v5 as well
There should be some condition, if width/height of image is equal of target size, then dont show crop window. Before your pull it works, if I cancel window. Can you look at it?
edit: upps, there should be OR, not AND
else{
if ( (data['width'] !== $options.data('width')) || (data['height'] !== $options.data('height') ) ) {
if($options.data('force_crop')){
initCrop($field);
}
}
}
$field.find('.cancel-crop-button').click(function(e){
e.preventDefault();
var iW = $options.find('.crop-stage img.crop-image').data('width'),
iH = $options.find('.crop-stage img.crop-image').data('height');
cancelCrop($field);
if ( $options.data('width') !== iW && $options.data('height') !==iH && $options.data('force_crop'))
removeImage($field);
});
Author is clearly not accepting improvements, and I no longer work for the company that uses (a fork of) this. Closing this out.
If the user cancels the crop then the image is not cropped. If one or both of the image's dimensions are too small, the crop window does not appear and the image is also not cropped.
If the image is not cropped, the user can still save it, resulting an image of an undesirable ratio being saved. This change ensures that the image selection is removed if the user cancels the crop or the image is too small.