🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How to Change the Default Product Image Size in Magento 2

By Sanjay JethvaUpdated on May 22, 2025 2 min read

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:
<theme_dir>/etc/view.xml;
  • Then switch to the <images module=”Magento_Catalog”> where all the image properties are configured. For this, use the following command:
<images module="Magento_Catalog">
...
<images/>;
  • You need to know an image id and type attributes to change or edit its properties:
<images module="Magento_Catalog"> 
 
<image id="unique_image_id" type="image_type"> ... 
 
</image>
 
<images/>

You may refer Images properties for a theme

Likewise you can also resize specific product image in Magento 2 using custom console command.
I’d be happy to solve them and might be useful to other readers too!

Thank You

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.