This page includes tips and useful modules for displaying product images in Drupal Commerce.
Drupal Core Image module
The Image module defines the image field type and provides image manipulation tools. It is installed by default in a standard Drupal 8 site. To help maintain consistency for the display of your product images, you can set up a custom image style. This image style will appear as one of the options for Image field formatters.
Example: Create a Product image style
- Navigate to the Image styles administration page at
- Click the Add image style button.
- Enter "Product (570×570)" for the Image style name.
- Click the Edit button next to the automatically created Machine name to change the machine name to "product".
Select the Scale Effect.
- Click the Add button to add the Scale effect.
- Enter "570" for both the Width and the Height values.
- Click the Add effect button.
The Product (570x570) image style will now appear as an option for Image field formatters.
Image Delta Formatter module
The Image delta formatter module provides a custom formatter for image fields that are configured for multiple images. It allows the user to specify which images (deltas) should be displayed. It can be useful in cases in which a product or product variation has multiple images, but in a certain context, you only want to display a single image. For example, if you want to display multiple products in a uniform grid layout, showing just a single image per product looks best.
Example: Create a custom Single image view mode for product variations
See the Multi-product displays documentation for an example of how this custom view mode can be used.
- Start by installing the Image delta formatter module in the usual way.
- Navigate to the View modes administration page at
- Scroll down to the Product variation entity type and click the Add new Product variation view mode link.
- Enter "Single image" for the Name and click the Save button.
- Navigate to the Manage display administration page for your product variation type at
/admin/commerce/config/product-variation-types/simple/edit/display (for the Simple product variation type).
- Click on Custom Display Settings to enable the Single image view mode.
- Click the Save button.
- Click on the Single image link that now appears at the top of the Manage display administration page.
- Drag the Price field to the Disabled section.
- Set the Images field Label to Hidden.
- Set the Images field Format to Image delta.
- Click the gear icon in the rightmost column to set the image delta formatter's Image style to the Product (570x570) image style (or another preferred image style).
- Click the Update button to close the formatter configuration form.
- Click the Save button to save the settings for the Single image product variation display.
The Single image view mode will now be an option for displaying product variations.
Links and resources