• I am using WooCommerce for my site. I need to change the crop method and size for some built-in images. In order to do that, I added this snippet to functions.php.

    function override_image_size_settings() {
    	add_image_size( 'shop_single', 600, 750, false );
    	add_image_size( 'shop_catalog', 450, 600, array( 'center', 'top' ) );
    }
    add_action( 'init', 'override_image_size_settings', 11 );

    This removes those images sizes from the list available on the page that says “Edit crop formats from full image” at the top.

    I have also tried adding the function above with this call:
    add_action( 'after_setup_theme', 'override_image_size_settings');

    I have tried both “add_action” calls with and without the priority of 11.

    If I comment out the “add_action” the image sizes appear immediately and can be edited without a problem. I love this plugin. I hope this is something that can be addressed easily. Please let me know if there is any information that I did not provide that would be helpful.

    Thanks,
    Swani

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter swani

    (@swani)

    OK, I have been playing around with this some more. It turns out that the part that makes this fail is the setting for the cropping behavior. Anything other than true will remove the image from the list of available crop sizes.

    Plugin Author sirulli

    (@sirulli)

    Hi @swani, yes you are right.
    Only the image sizes which have the “hard crop” option set to true are handled by the manual crop interface of YoImages.
    This is because “soft crops” are actually resizes of the original image (so nothing of the original image is missing, therefore there is no need to adjust the crop result manually).
    Regards,
    Team Sirulli

    Thread Starter swani

    (@swani)

    Hi @sirulli,

    I can see how a soft crop isn’t necessarily going to be missing any of the image, but that isn’t always the case. I think the easiest thing would be to give the example that I am working with.

    I have a client who sells clothing. Each article of clothing has one image of a model wearing the item. Some of these images are very tall and skinny. They come from the photographer that way. So, let’s say the raw image is 1000×2000. The images on the website are 450×600. Still a tall image, but nowhere near as tall, in terms of aspect ratio, as 1500×2500. In fact, simple resize two 450 pixels wide would result in an image that is 450×750. So a soft crop to 450×600 actually removes 150 pixels from the top or bottom of the image. What I want to do is give my client the option of redoing the crop depending on whether the product is in the top or bottom half of the image. If the item is a sweater, they might keep the crop as is, because the crop is set to crop the bottom off:

    add_image_size( 'shop_catalog', 450, 600, array( 'center', 'top' ) );

    But, if the item is a pair of pants or shoes, I want them to be able to recrop from the bottom. Obviously this would be done only for products that need it, but the code above that changes the default crop settings removes this crop size from the sizes available to recrop. Would you consider changing the plugin to allow this or maybe make it an option that can be enabled? I don’t have the programming chops to make that kind of change myself.

    Regardless of the decision you come to, thanks very much for making this. I think it’s great.

    Best,
    swani

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘using add_image_size removes image size from “Edit crop formats” page’ is closed to new replies.