fbpx
Want To Add Extra Images Per Product Variation For Free? Download Now

Prevent thumbnail images from cropping

Kitty Nicol

Hi there, I’ve asked this question in the forum, but no one seems to be answering there anymore, so trying my luck here.

I’m trying to figure out how to prevent the thumbnail images from cropping so that they show the whole image proportionally within the thumbnail size.

I have tried

add_filter( 'woocommerce_get_image_size_gallery_thumbnail', function( $size ) {
return array(
'width' => 150,
'height' => 150,
'crop' => 0,
);
} );

But this hasn’t changed how the thumbnails display in the gallery.

Could you please advise how I can change this?

Thanks

Hakik Zaman

Hi Kitty,

Thank you for getting back to us. Please kindly do a plugin compatibility check by doing these steps to identify the error :

=> Deactivate all of your additional plugins except the WooCommerce and Additional Variation Images Gallery Plugin.

=> See if the problem persists. If the issue is resolved, you can tell which plugin might be the culprit of this error by activating your additional plugins one by one.

If the plugin conflict check doesn’t help, please record me reproducing your issue using a tool like this. https://www.useloom.com
It helps me to figure out the issue quickly.

And don’t forget to add your site login details in the site login details area. I’ll check what’s happening there.

You can add new users by going to Users > Add New set the user and password for us, set the role to admin, and set the info here.

And add your site URL, login username, and password in the site login area. Follow this guideline: https://www.useloom.com/share/27c1f2ac633c4060b2da883d946107d7

Hope to hear from you soon!

Thank you

Kitty Nicol

Hi, thanks very much for the reply.

The issue is not a conflict. I’m simply asking how to go about changing the thumbnails that you are using for the gallery. I can see these image sizes are registered:

variation_swatches_image_size: 50×50 pixels (cropped to fit)
variation_swatches_tooltip_size: 100×100 pixels (cropped to fit)

I assume that these are being used by the plugin as the thumbnails in the gallery and are being cropped. All I’m trying to do is change the setting so that the thumbnails are not cropped, but the image remains proportional. I do not believe this is a plugin conflict issue, I’m just not sure how to change the thumbnail cropping. Please see in my original comment the option that I have tried which is what WooCommerce recommends to change the thumbnail size/crop.

Any help is appreciated!

Thank you

Kitty

Hakik Zaman

Hi Kitty,

Yes, I have already checked the original comment. You have tried the right code block.

If it is not working that means any plugin or your theme overriding
woocommerce_get_image_size_gallery_thumbnail
That’s why I am saying to check the conflict.

Thank You