• Resolved KarenWallace

    (@karenwallace)


    My WooCommerce thumbnail cropping setting is 1:1 in the Customer, and a 100×100 thumbnail of the product image exists, but the gallery is displaying the full-size rectangular image as the thumbnail for the first image (the rest of the images use the 100×100 thumbnails).

    I tried the solution in the Wrong size first (product) thread of adding a PHP snippet:

    add_filter( 'woocommerce_gallery_thumbnail_size', function( $size ) {
        return 'thumbnail';
    } );

    That had no effect, so I added this for good measure:

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

    Still no effect. Is there something else I can try?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor codeixer

    (@codeixer)

    use this plugin to check if your code overrides the default size or not https://www.ads-software.com/plugins/regenerate-thumbnails/
    you can see all image size lists into the regenerate thumbnails settings page.

    Thread Starter KarenWallace

    (@karenwallace)

    With or without my code, the woocommerce_gallery_thumbnail is 100×100, so my theme must be setting it to 100×100, which would explain why the PHP snippet had no effect:

    woocommerce_gallery_thumbnail: 100×100 pixels (cropped to fit)

    I disabled the slider plugin and verified that the first thumbnail image correctly uses the 100×100 size when the plugin is disabled, but with the slider enabled, the first thumbnail becomes rectangular and doesn’t use the small thumbnail image.

    Plugin Contributor codeixer

    (@codeixer)

    send a product link to check the issue.

    Thread Starter KarenWallace

    (@karenwallace)

    I found the problem and a solution.

    In inc/product-thumbnail.php on line 35, the code reads passes ‘shop_thumbnail’ as the image size to wp_get_attachment_image(). If you pass $thumbnail_size instead, it fixes the display issue.

    Plugin Contributor codeixer

    (@codeixer)

    Sounds Great!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘First gallery image wrong aspect ratio’ is closed to new replies.