Thumbnail sizes not reflected correctly
-
Hi there! I have an issue with WooCommerce thumbnails in the following two cases that don’t seem to respect the thumbnail size I’ve configured.
Case 1: images displayed by the Gutenberg product category block
Case 2: using $_product->get_image(‘thumbnail’) within a hookI’m using the following code to increase the thumbnail size to 300 pixels instead of 150 pixels but this doesn’t seem to take effect. Is there something missing here to override the default thumbnail size?
function redefine_woocommerce_thumbnail_size() {
add_image_size( ‘woocommerce_thumbnail’, 300, 300, true );
}
add_action( ‘after_setup_theme’, ‘redefine_woocommerce_thumbnail_size’ );add_theme_support( ‘woocommerce’, array(
‘thumbnail_image_width’ => 300,
) );In the customizer, images are set as “uncropped”.
The images appear with a full source set including high res sources. But the sizes attribute looks like this:
sizes=”(max-width: 150px) 100vw, 150px”This means the higher res versions are available but are ignored by the browser and the low resolution version is displayed instead. If I manually remove the sizes attribute the images are displayed correctly.
I’ve tried regenerating thumbnails from the WooCommerce settings, but as mentioned above the issue doesn’t seem to be with the files but rather with the markup and the sizes attribute.
- The topic ‘Thumbnail sizes not reflected correctly’ is closed to new replies.