• Resolved boostxd

    (@boostxd)


    Hi,

    I need to set fixed height for all single products of grid layout to avoid overflows and layout breaks. Woocommerce by default crops width of all images, but unfortunately the same isn’t done to height.

    add_theme_support(
    				'woocommerce',
    				apply_filters(
    					'storefront_woocommerce_args',
    					array(
    						'single_image_width'    => 416,
    						'thumbnail_image_width' => 324,
    						'product_grid'          => array(
    							'default_columns' => 3,
    							'default_rows'    => 4,
    							'min_columns'     => 1,
    							'max_columns'     => 6,
    							'min_rows'        => 1,
    						),
    					)
    				)
    			);
    • This topic was modified 2 years, 7 months ago by boostxd.
    • This topic was modified 2 years, 7 months ago by boostxd.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Tamirat B. (a11n)

    (@tamirat22)

    Hello @boostxd!

    Thanks for reaching out!

    I need to set fixed height for all single products of grid layout to avoid overflows and layout breaks. Woocommerce by default crops width of all images, but unfortunately the same isn’t done to height.

    I understand you want to adjust your product image thumbnail size through some hook script.

    We have addressed that particular use case in our guide here: https://woocommerce.com/document/image-sizes-theme-developers/#section-3

    The following code will change gallery thumbnails to 150x150px uncropped images. You could adjust the width and height values to suit your needs.

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

    Don’t forget to Regenerate shop thumbnails under WooCommerce→Status→Tools once you are done with your customizaitons.

    Hope this helps!

    Which file is the code above is placed? Tried Woo>Status>regen shop thumbnails as directed by my theme already.

    Regenerating did nothing. This is such a waste of time to not force uniform sizing out the box.

    Hi @functionmunchkin

    Thanks for reaching out!

    Which file is the code above is placed? Tried Woo>Status>regen shop thumbnails as directed by my theme already.

    You can add the code using the Code Snippets plugin or create a child theme and add the PHP snippet to the functions.php file within the child theme.

    Hope this helps!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to regenerate thumbnail height for product shop page?’ is closed to new replies.