0

I want to remove white background from thumbnail images in my custom theme.

I have created custom theme for Magento 2.1.3 I made changes in order summary layout but when I try to load images on checkout page, it comes with white background at top and bottom.

I tried almost all solution available on stack overflow but no luck. Any help would me appreciate.

enter image description here

4
  • Not sure about Magento2 but in magento1 we used to add keepFrame(false) before resizing an image. You can try that also. Commented Apr 11, 2017 at 10:01
  • I guess you can set a custom height and width to the image..So you can extend the images till the edge of the white background covering entire white space..
    – Kartik
    Commented Apr 11, 2017 at 10:03
  • Try this on your image object ->setKeepFrame(false). You can find this on this class Magento\Catalog\Model\Product\Image Commented Apr 11, 2017 at 10:05
  • @Kartik, this won't work. i did try. Commented Apr 11, 2017 at 12:09

2 Answers 2

4

In <vendor>/<theme>/etc/view.xml you should be able to adjust the settings of the image to remove the frame, like this:

<image id="category_page_grid" type="small_image">
    <width>610</width>
    <height>360</height>
    <frame>false</frame>
</image> 

However, there is an issue where setting <frame> to false returns true. See this Github issue, it was recently merged into the develop branch. If you're not using the develop branch for your site you'll still need to use the below fix until it's offically released:

After creating a plugin to convert the string value to an integer (which properly casts to a boolean), the image frame is not added.

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

You have to add false to view.xml in YOUY_THEME/etc/view.xml to the "category_page_list"

<?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="category_page_list" type="small_image">
                <width>240</width>
                <height>300</height>
                <transparency>false</transparency>
            </image>
        </images>
    </media>
</view>

You can also check here https://magento.stackexchange.com/a/148911/43587

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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