Resizing thumbnails in WooCommerce

After the next update of WooCommerce, not all thumbnail sizes can be changed through the WordPress admin panel. It used to be like this:

Now the settings are moved to the menu item "Appearance -> Customize"
:

And now there is no such flexibility of settings as before. The necessary settings can now be made only with the help of the code:

-for catalog image

add_filter('woocommerce_get_image_size_thumbnail','add_thumbnail_size',1,10);
function add_thumbnail_size($size){

    $size['width'] = 300;
    $size['height'] = 300;
    $size['crop']   = 1; //0 - full, 1 - crop
    return $size;
}

- for the image on the product page

add_filter('woocommerce_get_image_size_single','add_single_size',1,10);
function add_single_size($size){

    $size['width'] = 600;
    $size['height'] = 600;
    $size['crop']   = 0;
    return $size;
}

- for miniatures in the product gallery

add_filter('woocommerce_get_image_size_gallery_thumbnail','add_gallery_thumbnail_size',1,10);
function add_gallery_thumbnail_size($size){

    $size['width'] = 100;
    $size['height'] = 100;
    $size['crop']   = 1;
    return $size;
}

To recreate the thumbnails, you can use the plugin Force Regenerate Thumbnails .


Updated: 18.11.2018

Did this article help you? Rate it!
(No Ratings Yet)
Loading...


Leave a Reply

Your email address will not be published. Required fields are marked *