Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #982829

    Hi
    2 days ago I declared a problem solved (#977561) now I get a variation of the problem, but on a different website.
    In the first website I was unable to set the shop thumbnail size to the same size regardless of their orientation.
    What I wanted was
    – portrait = 300 x 200px (width x height)
    – landscape = 200 x 300px (with x height).
    Same size whether landscape or portrait.

    The landscape thumbnails were correct, but the portraits were much too high.

    Ismael suggested the following addition to the flashlight file functions.php:

    add_filter( ‘woocommerce_gallery_thumbnail_size’, ‘custom_woocommerce_gallery_thumbnail_size’ );
    
    function custom_woocommerce_gallery_thumbnail_size() {
    return ‘thumbnail’;
    }
    function ratio_check_by_image_size($attachment)
    {
    	$img_size = ' square';
    	if(!empty($attachment[1]) && !empty($attachment[2]))
    	{
    		if($attachment[1] > $attachment[2]) //landscape
    		{
    			//only consider it landscape if its 1.7 times wider than high
    			if($attachment[1] > $attachment[2]) $img_size = 'landscape';
    		}
    		else //same check with portrait
    		{
    			if($attachment[2] > $attachment[1]) $img_size = 'portrait';
    		}
    	}
    	return $img_size;
    }
    
    add_filter('woocommerce_get_image_size_thumbnail', 'woocommerce_get_image_size_thumbnail_mod', 10, 2);
    function woocommerce_get_image_size_thumbnail_mod($size) {
    	global $product;
    	$image = wp_get_attachment_image_src( $product->image_id, 'full' );
    	$orientation = ratio_check_by_image_size($image);
    
    	if($orientation == 'portrait') {
    		$size['width'] = 200;
    		$size['height'] = 300;
    	} else {
    		$size['width'] = 300;
    		$size['height'] = 200;
    	}
    	
    	$size['crop'] = 0;
    	return $size;
    }

    This worked fine. Now I repeated the same procedure with a different website.
    The size of the landscape thumbnails still looks fine, but the portrait thumbnails show too small in height. Their height is only 200px (same as the landscapes) – the height of portraits should be 300px

    Simple-image-size does no longer work (tested). The WC customizer does not help (tested).

    Both website installations are almost the same. their main difference:
    – single products / variable products
    – different custom.css

    I still want landscape-thumbnail-height = portrait-thumbnail-width
    Or
    – portrait = 300 x 200px (width x height)
    – landscape = 200 x 300px (with x height).

    I wonder whether some code in a modified file may interfere (functions.php, custom.css). Unfortunately I have no clue what to look for.
    Strange: the same code addition produces different results !

    Can you identify the problem and suggest a remedy?

    Thanks,
    Bruno

    #983949

    Hey bruwa,

    Thank you for using Enfold.

    The size of the images are correct. (see private field)

    Best regards,
    Ismael

    #984172

    Hi Ismael
    yes, I know that the physical dimensions of the images are correct, but they are not displayed with this size.
    What matters is what the user sees on the screen
    Please compare the the two websites:(private field)

    – On the first website the verticals are displayed as height_vertical = width_horizontal, which is correct.
    – On the second website the verticals are displayed as height_vertical = height_horizontal, which is NOT correct

    The container seems to be too small in height to accommodate verticals of 300px height.
    Something must be wrong if an image of 300px height is displayed as 200px of height.

    The verticals are displayed too small in height, despite their correct physical size!!

    Thank you
    Bruno

    • This reply was modified 2 months, 1 week ago by  bruwa.
    #984236

    Hi
    please have a look at the screenshots (private field).

    Please note the different size of the verticals.

    Both verticals are technically of the same size (200 x 300px) – why don’t they display with the same size?
    The horizontals do.

    Thank you
    Bruno

    #984292

    Hi
    I added

    #top .thumbnail_container img {
        min-width: 200px;
        margin-right: auto;
        margin-left: auto;
    }
    

    to the custom.css – and BINGO – problem solved.
    You can close this ticket.

    Thank you
    Bruno

    • This reply was modified 2 months, 1 week ago by  bruwa.
    • This reply was modified 2 months, 1 week ago by  bruwa.
    #984414

    Hi,

    Awesome! Glad that you figured it out. :)

    Please take a moment to review our theme and show your support https://themeforest.net/downloads
    Don’t forget to bookmark Enfold Documentation for future reference.

    Thank you for using Enfold :)

    Best regards,
    Ismael

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

The topic ‘Thumbnail size problem after WC update (2.6.8 to 3.4.3)’ is closed to new replies.