[Resolved] change the gallery Thumbnail size in woo commerce

  • Author
    Posts
  • #9498

    Alexia Jolliot
    Participant

    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

    #9515

    Andrew Misplon
    Keymaster

    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 🙂

    #9522

    Alexia Jolliot
    Participant

    Hi Andrew,

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

    Cheers,
    Alexia

    #9523

    Andrew Misplon
    Keymaster

    Super, glad to hear that helped 🙂

    All the best.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Scroll to top