Question

Please check the below code

app\code\Vendor\Category\etc\di.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">

    <type name="Magento\Catalog\Model\Product\Image">
        <plugin name="ImageWhitespace" type="Vendor\Category\Model\Product\Image" sortOrder="1" />
    </type>
</config>

app\code\Vendor\Category\Model\Product\Image.php

<?php

namespace Vendor\Category\Model\Product;

    class Image
    {
        public function beforeSetKeepFrame($image, $keep)
        {
            if (is_string($keep)) {
                $keep = (strtolower($keep) === 'true') ? 1 : 0;
            }
            return [$keep];
        }
}
    ?>

app\design\frontend\vendor\customtheme\etc\view.xml

 <?xml version="1.0"?>
    <!--
    /**
     * Copyright © Magento, Inc. All rights reserved.
     * See COPYING.txt for license details.
     */
    -->
    <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="category_page_list" type="small_image">
                <width>237</width>
                <height>341</height>
                <frame>false</frame>
            </image>
             <image id="product_page_image_medium" type="image">
                    <width>295</width>
                    <height>400</height>
                    <frame>false</frame>
                </image>

                <image id="upsell_products_list" type="small_image">
                    <width>237</width>
                    <height>341</height>
                    <frame>false</frame>
                </image>

                 </images>
        </media>
    </view>
Was it helpful?

Solution

Product images are cached while saving the product from admin panel. However, sometimes you may need to re-create the product images cache after you import products, if images were resized manually in the cache, or if the cache was manually cleared by mistake.

Command :

php <magento install dir>/bin/magento catalog:images:resize

This command takes no arguments or options,The message Product images resized successfully. displays to confirm the command succeeded.

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