Suggestion: Clear field if image size insufficient for crop
-
Hi,
Considering we are enforcing an image size to be cropped at by using this plugin, to me it makes more sense for the image field to be cleared if an inappropriate sized image is selected. At the moment, a user selects an image, is warned if the image size is not large enough but then nothing happens. At this point, a user can update the page/post and that incorrect image size is saved on the field – meaning the image could appear on the front end displayed at the wrong size for the theme’s design.
If you’d like the image field to be cleared if it is not at the required crop size, then edit input-v4.js and find this line (about line #50)
if(!valid){ $field.addClass('invalid'); $field.find('.init-crop-button').attr('disabled', 'disabled'); alert('Warning: The selected image is smaller than the required size:\n' + warnings.join('\n'));
Then, add this directly underneath:
$( ".acf-image-uploader .acf-button-delete" ).trigger( "click" );
(Before this part)
} else{
Now, as soon as the user clicks OK, the image field is cleared. So if a post is updated, the wrong image crop size will not be saved to the post.
- The topic ‘Suggestion: Clear field if image size insufficient for crop’ is closed to new replies.