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

  • Not sure about Magento2 but in magento1 we used to add keepFrame(false) before resizing an image. You can try that also. – Kingshuk Deb Apr 11 '17 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 Apr 11 '17 at 10:03
  • Try this on your image object ->setKeepFrame(false). You can find this on this class Magento\Catalog\Model\Product\Image – Kingshuk Deb Apr 11 '17 at 10:05
  • @Kartik, this won't work. i did try. – Developer Webile Apr 11 '17 at 12:09

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">

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];

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">
        <images module="Magento_Catalog">
            <image id="category_page_list" type="small_image">

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, privacy policy and cookie policy

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