1

How can I resize the images rendered via the recently viewed product widget?

I have tried editing multiple values inside

app/design/frontend/VENDOR/THEME/etc/view.xml

but none updated the recently viewed image sizes.

They are currently rendering at 135px in height and width, the only values set at 135 is shared_wishlist_email and product_small_image. Neither of those changed the image size.

1

I have done something similarly but for the img on the product page. What I did: I changed the block that load my img.

In my di.xml:

 <type name="Magento\Catalog\Block\Product\View\Gallery">
        <plugin name="plugin_block_catalog_product_view_gallery"
                type="Namespace\Vendor\Block\Catalog\Product\View\Gallery"
                sortOrder="10"
                disabled="false"/>
 </type>

and i rewrite this block by changing the path of the img like this :

public function getGalleryImagesJson()
    {   
        $product = $this->getProduct();
        $imagesItems = [];
        foreach ($this->getGalleryImages() as $image) {

            $imagesItems[] = [
                'thumb' => $this->getBaseUrl().'pub/media/catalog/product/'.$image['file'],
                'img' => $this->getBaseUrl().'pub/media/catalog/product/'.$image['file'],
                'full' => $this->getBaseUrl().'pub/media/catalog/product/'.$image['file'],
                'caption' => $image->getLabel(),
                'position' => $image->getPosition(),
                'isMain' => $this->isMainImage($image),
            ];
        }
        if (empty($imagesItems)) {
            $imagesItems[] = [
                'thumb' => $this->_imageHelper->getDefaultPlaceholderUrl('thumbnail'),
                'img' => $this->_imageHelper->getDefaultPlaceholderUrl('image'),
                'full' => $this->_imageHelper->getDefaultPlaceholderUrl('image'),
                'caption' => '',
                'position' => '0',
                'isMain' => true,
            ];
        }
        return json_encode($imagesItems);
    }

I know is not what you need, but this may help you.

0

Use this in your view.xml:

<image id="recently_compared_products_images_only_widget" type="thumbnail">
   <width>110</width>
   <height>110</height>
</image>

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.