Support » Plugin: Advanced Custom Fields: Image Crop Add-on » 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.

    https://wordpress.org/plugins/acf-image-crop-add-on/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author andersthorborg

    (@andersthorborg)

    Hi there,

    Thank you for your suggestion.

    I guess this behavior should be an option under the field settings, as I don’t think disallowing the user to use smaller images fits every scenario.

    I’ll look into this.

    Best,

    Anders

    Hi Anders, thanks for the easy to use extension. I’d like to second an upgrade to reject the image outright if it is too small, as opposed to just a warning.

    I also think that an option forcing to have a minimum size image would be useful.
    Thx for the extension

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Suggestion: Clear field if image size insufficient for crop’ is closed to new replies.