10

I am having a problem with how my images are displaying on my Magento 2 store.

And also I would like to know:

What does catalog:images:resize in Magento 2.x version ?

2
  • 1
    Are you asking of php bin/magento catalog:images:resize
    – Arjun
    Commented Aug 10, 2016 at 7:25
  • Yes i am asking in regards to php bin/magento catalog:images:resize
    – Jiyaad.D
    Commented Aug 10, 2016 at 7:35

3 Answers 3

12

Generally, 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 usage:

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.

Source: http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/themes/theme-images.html#resize-catalog-images

2
  • 1
    is there any way to catalog images resize for particular theme? Suppose i have 4 themes and i want to resize images only for one theme then how can i achieve this?
    – Rik Patel
    Commented Aug 13, 2020 at 7:41
  • With this command, there is no such way. Although you can customize the logic by overriding /vendor/magento/module-catalog/Console/Command/ImagesResizeCommand.php/ file. Commented Aug 13, 2020 at 10:44
6

The images size is defined in view.xml of <theme_dir>/etc/view.xml. You can also manually modify according to your requirement. For eg:

<images module="Magento_Catalog">
    <image id="unique_image_id" type="image">
        <width>100</width> <!-- Image width in px --> 
        <height>100</height> <!-- Image height in px -->
    </image>
</images>

But, if you have following conditions:

 1. If you imported products which might have variable sized images
 2. If images were resized or deleted manually from cache

The magento catalog:images:resize command enables you to resize images for display on your storefront.

I hope this helps you !!

2
  • is it a good idea to modify this file?
    – Jiyaad.D
    Commented Aug 11, 2016 at 7:23
  • YES. You can. Copy view.xml of parent theme and paste to your theme with same folder directory. Now you can change view.xml of your theme as per your requirement. Commented Aug 11, 2016 at 8:26
3

php bin/magento catalog:images:resize

It creates resized product images.

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.