How to resize image of product details page in Magento 2?


  • I want to do keep frame false on this. Can I do this in view.xml file? Dec 24, 2019 at 6:48

2 Answers 2


Magento uses the file called view.xml which is maintained at the theme level of the application.

So for example, if you are using the default theme luma you should find the view.xml under vendor/magento/theme-frontend-luma/etc/view.xml

In this file, you would see node inside the node.

The dimension of the images is maintained here under the node.

The id attribute value of the node is referenced in the code base.

    <image id="product_page_main_image" type="image">
    <image id="product_page_main_image_default" type="image">

You can define your custom view.xml in your theme and define width & height as per your requirement.

In case of changing/overwriting the values of the view.xml file you need to completely copy the entire view.xml file to your custom theme and change the values.

view.xml does not have a node value fallback system, means if a value of a node is not present in your custom theme's view.xml it will not fallback to its parent theme's view.xml value, that's why the entire file needs to be copied.

Once the values changes have been done, you will have to run

php bin/magento catalog:images:resize

This will regenerate the new image sizes.

You can take reference this answer How to resize image of product view page in Magento 2?

  • If its use full, Accept it so others can also use for reference.
    – Yogesh
    May 9, 2018 at 15:17
  • i check and inform you May 9, 2018 at 15:27
  • not working now so Magento 2 Not Building Product Thumbnails Cache May 9, 2018 at 15:36
  • Are you checking on local server or production ?
    – Yogesh
    May 9, 2018 at 15:46
  • Why is there a separate product_page_main_image and product_page_main_image_default and not just 1 size? I don't see the added value of the _default variation. Is there a reason for that?
    – Wouter
    Sep 8, 2020 at 8:12

Edit vendor\theme\etc\view.xml. Attributes for product page images are:




  • but issue is Magento 2 Not Building Product Thumbnails Cache May 9, 2018 at 14:56
  • Run bin/magento deploy:mode:set production
    – Madn3ss795
    May 10, 2018 at 2:34

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.