0

I have my image sizes set in my app/design/frontend/My_Design/My_Theme/etc/view.xml but for some reason, the values for mini_cart_product_thumbnail are not being used in the minicart.

<view xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/view.xsd">
    <media>
        <images module="Magento_Catalog">
            ...
            <image id="mini_cart_product_thumbnail" type="thumbnail">
                <width>76</width>
                <height>76</height>
            </image>
            ...
        </images>
    </media>
</view>

I have tried changing the type from thumbnail to small_image but it makes no difference.

Inspecting the output HTML, I see that the image sizes are being set to auto:

<img class="product-image-photo"
data-bind="attr: {src: src, alt: alt}, style: {width: 'auto', height: 'auto'}"
src="image_url" alt="Image Alt Text" style="width: auto; height: auto;">

The visual result is thus:

Mini-Cart showing very small product image

Other places using this same XML file are adjusting the sizes accordingly, any thoughts greatly appreciated.

Many thanks.

1 Answer 1

2

The config for Mini cart thumbnail image was changed recently since magento 2.4.0. So, if your magento version is >= 2.4.0, you have to double the size of width, height, so your new code will be changed to:

<image id="mini_cart_product_thumbnail" type="thumbnail">
    <width>152</width>
    <height>152</height>
</image>

Reference: https://github.com/magento/magento2/pull/24743/files

Btw, you should inspecting the output HTML div .product-image-container instead of product-image-photo

2
  • This worked like a charm, thank you so much!
    – fearfelt
    Oct 7, 2022 at 12:13
  • Glad to hear that. Cheers!
    – Tu Van
    Oct 7, 2022 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.