The media object represents an object in a product.media array. It is an abstract object that can represent these object types:

Use media filters to create URLs and model viewer tags that render the media on the product page.

Note: In VersaCommerce product.media currently contains only images (it is an alias of product.images). Videos and 3D models are not returned through product.media.

The media object has the following attributes. Attributes that are specific to a media type are also available; see the reference of each supported object type.

media.alt

Returns the alt text of the media, set on the products page in the admin.

media.id

Returns the ID of the media.

media.media_type

Returns the media type of the object.

Use media_type to filter the product.media array for all media of a given type.

{% assign images = product.media | where: "media_type", "image" %}
{% for image in images %}
  {{ image.alt }}
{% endfor %}
Image of the black stroller
Image of the grey stroller

media.position

Returns the position of the media object in the media array of the product object.

media.preview_image

Returns a preview image for the media.

Preview images have no ID attribute.