Question

I need to change the size of the small images below the gallery, but only for products of type grouped

enter image description here

Normaly you can change the size in the file THEME/etc/view.xml:

<?xml version="1.0"?>
<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="product_page_image_small" type="thumbnail">
                <width>110</width>
                <height>110</height>
            </image>
            ...

So I tried to change it for grouped products only like this:

<?xml version="1.0"?>
<view xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/view.xsd">
    <media>
        <images module="Magento_GroupedProduct">
            <image id="product_page_image_small" type="thumbnail">
                <width>129</width>
                <height>129</height>
            </image>
        </images>
        <images module="Magento_Catalog">
            ...
            <image id="product_page_image_small" type="thumbnail">
                <width>110</width>
                <height>110</height>
            </image>
            ...

Then I flushed the cache. But it does not work. The image size still stays 110px instead of 129px.

Was it helpful?

Solution

I figured it out. Had to overwrite the method getImageAttribute of the class Magento\Catalog\Block\Product\View\Gallery

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top