1

i want to remove white background for product image but it's not working all... i have apply How to remove white background from product images in Magento 2.2.6? this solution but still same..

Please check SS for slider https://nimb.ws/RpcNFm

<image id="category_page_list" type="small_image">
                <width>240</width>
                <height>300</height>
                <transparency>false</transparency>
                <aspect_ratio>false</aspect_ratio>
                <frame>false</frame>
            </image>

Thanks in advance for help !!

0

It's Maybe Magento Core issue. Not sure, It's solved or not. But, If you didn't get result using XML change then, you can create plugin for that :

app/code/RH/Helloworld/etc/di.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
  <type name="Magento\Catalog\Model\Product\Image">
    <plugin name="remove_white_bg_plugin" type="RH\Helloworld\Plugin\Product\Image" sortOrder="1"/>
  </type>
</config>

Create Plugin File :

app/code/RH/Helloworld/Plugin/Product/Image.php

<?php

namespace RH\Helloworld\Plugin\Product;

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

Clean cache and check it.

1
  • For testing purpose i have added above code to Magento\Catalog\Model\Product\Image file directly but it's not working...... Original image has white background and it's jpg image any another way for same... thanks @rohan – rakesh prajapati May 1 '20 at 4:32

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.