Please check the below code


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



namespace Vendor\Category\Model\Product;

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


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

                <image id="upsell_products_list" type="small_image">


1 Answer 1


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.

  • ,i did it but still whitespace are coming Jan 18, 2019 at 7:09
  • in my case if in catagory list page size image is adding then it is fine here with no whitespace but for details page and upsell products images are coming with whitespace Jan 18, 2019 at 7:12
  • 1
    white space coming,that mean images resize resolution is not correct, calculate the image resolution based on the original image size and then white space won't come Jan 18, 2019 at 7:13

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.