Resolved

change the gallery Thumbnail size in woo commerce

Ultra Theme started by Alexia Jolliot Apr 23, 2018 3 replies
Alexia Jolliot Apr 23, 2018 · 9:05 am #9498

Hi Andrew

Here is the new topic.

I’m using woo commerce and ultra premium and I would like to modify the gallery thumbnail size in the product page. I understand it can’t be done through the customizer and should be done with CSS or PHP. You suggest PHP but I have no clue how PHP works.
I would like the image in the gallery thumbnail to keep their original aspect ratio which is : Height : 3 * width : 2 so ideally it would be 150px* 100 px

Many thanks
Alexia

Andrew Misplon Puro Apr 24, 2018 · 7:58 am #9515

Hi Alexia

Thanks for the wait. To make this change, download this file by right clicking and saving as:

https://purothemes.com/wp-content/uploads/2018/04/woocommerce-thumbnails.code-snippets.json

Then go to Plugins > Add New, search for and install Code Snippets. Then go to Snippets > Import and import the file.

If you’re using a child theme and would prefer to insert the function directly into your child theme functions.php file, please find it below:

if ( ! function_exists( 'ultra_woocommerce_single_gallery_thumbnail_size' ) ) :
/**
 * Change the gallery thumbnail image size.
 * @link https://github.com/woocommerce/woocommerce/wiki/Customizing-image-sizes-in-3.3-
 */
function ultra_woocommerce_single_gallery_thumbnail_size( $size ) {
    return array(
        'width'  => 150,
        'height' => 100,
        'crop'   => 1,
    );	
}
endif;
add_filter( 'woocommerce_get_image_size_gallery_thumbnail', 'ultra_woocommerce_single_gallery_thumbnail_size' );

Hope that helps 🙂

Alexia Jolliot Apr 24, 2018 · 10:33 am #9522

Hi Andrew,

This is great ! Thanks a lot for your support, as always !

Cheers,
Alexia

Andrew Misplon Puro Apr 24, 2018 · 11:00 am #9523

Super, glad to hear that helped 🙂

All the best.

4 posts