Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1388069

    Hi All,
    Solution for Enfold users (Also works for most other WooCommerce WordPress Themes)
    I have been looking for something that fixes this problem in WooCommerce for a while.
    If your client uploads images in different aspect ratios and sizes into WooCommerce the shop grid and product pages will be extremely inconsistent.

    The following code makes it so imagery is a uniform size within the container making the standard woocommerce categories and grids less sensitive to image aspect ratio variations. I use square for most sites.

    NOTES – Please adjust the aspect ratio to suit your WooCommerce Settings!
    https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio

    /* Shop / Categories - Sets the aspect ratio of the image to square and contains the image within it */
    #top .thumbnail_container img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }
    
    #top .thumbnail_container {
    aspect-ratio:1/1;
    }
    /* Product Page - Sets the aspect ratio of the main product image to square and contains the image within it */
    #top .product div.images img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }
    
    .template-shop .single-product-main-image .images a {
        aspect-ratio: 1/1;
        overflow: hidden;
    }

    STOP ENFOLD CROPPING IMAGES IN SHOP
    In Functions.php in your child theme.

    
    add_action('after_setup_theme', 'update_enfold_image_sizes');
    	function update_enfold_image_sizes() {
    add_image_size ('shop_thumbnail', 200, 0, false );
    add_image_size ('shop_catalog', 450, 0, false);
    add_image_size ('shop_gallery_thumbnail', 300, 0, false);
    }
    
    • This topic was modified 1 year, 10 months ago by thinkjarvis.
    #1393865

    Hey Thomas,

    Thank you for this info. We will include it in the documentation.

    Best regards,
    Ismael

    #1393886

    Hi,

    Thanks, Thomas! We have added the information here: https://kriesi.at/documentation/enfold/woocommerce-shop/#make-woocommerce-images-in-the-shop-the-same-aspect-ratio :)

    Regards,
    Yigit

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.