How to Change the Default Product Image Size in Magento 2

How to Change the Default Product Image Size in Magento 2

Product images are the vital source for driving sales in E-commerce. In Magento 2, store owners need to combine them with different themes and it’s difficult to make product images look good on all of them. As a part of this process, the admin may require to change the default product image size in Magento 2 store.

The product images, thumbnail images, etc can be resized for better storefront and design, easy navigation, etc. Learn about the various image attributes and also the method to resize product image in Magento 2.


Magento 2 Image Attributes:

  • id (attribute)/ string (type): A unique parameter used in .phtml templates. It can be used to specify image properties for a specific location or page.
  • type (attribute)/ string (type): It defines the image to be displayed. It is identified by special id. The following are the values of the attributes:
    • image – corresponds to the Base Image role in the Magento 2 admin
    • small_image – corresponds to the Small Image role in the Magento 2 admin
    • swatch_image – corresponds to the Swatch Image role in the Magento 2 admin
    • swatch_thumb – corresponds to the Swatch Image role in the Magento 2 admin
    • thumbnail – corresponds to the Thumbnail Image role in the Magento 2 admin


List of Image Elements (Parameters):

  • Width – Allows changing the image width in pixels. (Type: IntegerDefault value: None)
  • Height – Allows changing the image height in pixels. (Type: IntegerDefault value: None)
  • Constrain – When set to true, the images that are smaller than specified value will be not enlarged. (Type: BooleanDefault value: True)
  • Aspect_Ratio – When set to true, the proportional relationship between the width and height stay consistent, even if it’s required by the configuration. (Type: BooleanDefault value: True)
  • Frame – When set to true, images are not cropped. This property is applied only when the aspect_ration is set to true. (Type: BooleanDefault value: True)
  • Transparency – Its default true value saves the transparent background image, otherwise the white background is saved. (Type: BooleanDefault value: True)
  • Background – Used to remove the white image frame when resizing photos and adjust background color to your theme. (Type: string, Default value: [255, 255, 255])


Method to Change the Default Product Image Size in Magento 2:

  • To find the view.xml configuration file use the next command:
  • Then switch to the <images module=”Magento_Catalog”> where all the image properties are configured. For this, use the following command:
  • You need to know an image id and type attributes to change or edit its properties:

You may refer Images properties for a theme

Please feel free to share your doubts in the Comments section below.
I’d be happy to solve them and might be useful to other readers too 🙂

Also, don’t forget to rate the post with 5 stars!

Thank You

Get Weekly Updates

Never miss Magento tips, tricks, tutorials, and news.

Thank you for subscribing.

Something went wrong.

(based on 19 Reviews)

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. Owing to his contributions in Magento Forums and posting solutions, he is among the top 50 contributors of the Magento community in 2019. When he is not engrossed with anything related to Magento, he loves to play cricket.

Leave a reply:

Your email address will not be published.