--- title: Support product media description: Learn how to support product media in your theme. source_url: html: https://shopify.dev/docs/storefronts/themes/product-merchandising/media/support-media md: https://shopify.dev/docs/storefronts/themes/product-merchandising/media/support-media.md --- ExpandOn this page * [Resources](https://shopify.dev/docs/storefronts/themes/product-merchandising/media/support-media#resources) * [Implementing product media](https://shopify.dev/docs/storefronts/themes/product-merchandising/media/support-media#implementing-product-media) * [UX considerations](https://shopify.dev/docs/storefronts/themes/product-merchandising/media/support-media#ux-considerations) * [Use media preview images](https://shopify.dev/docs/storefronts/themes/product-merchandising/media/support-media#use-media-preview-images) * [Support AR functionality](https://shopify.dev/docs/storefronts/themes/product-merchandising/media/support-media#support-ar-functionality) * [Control video functionality with parameters](https://shopify.dev/docs/storefronts/themes/product-merchandising/media/support-media#control-video-functionality-with-parameters) # Support product media Merchants can [add media](https://help.shopify.com/en/manual/products/product-media/add-media) to their products, like images, 3D models, videos, and YouTube or Vimeo videos. In this tutorial, you'll learn how to support product media in your theme. *** ## Resources * The `media` attribute of the [`product` object](https://shopify.dev/docs/api/liquid/objects/product#product-media) * [Media filters](https://shopify.dev/docs/api/liquid/filters/media-filters) *** ## Implementing product media Product media is usually displayed on the [product page](https://shopify.dev/docs/storefronts/themes/architecture/templates/product). However, you might want to display product media in other areas of your theme, so it's recommended to build your media display in a [snippet](https://shopify.dev/docs/storefronts/themes/architecture/snippets) so that it can be reused. To display product media, you can loop through the `media` attribute of the `product` object and apply the associated media filter, depending on the media type. ### Example If you want to output product media on the product page, and your product page content is hosted in a `product.liquid` section, then you might do the following: * Create a snippet called `media.liquid` to host your media display. * Render `media.liquid` in your `product.liquid` section. ## sections/product.liquid ```liquid {% for media in product.media %} {% render 'media', media: media %} {% endfor %} ``` ## snippets/media.liquid ```liquid {% case media.media_type %} {% when 'image' %}
{{ media | image_url: width: 2048, height: 2048 | image_tag }}
{% when 'external_video' %}
{{ media | external_video_tag }}
{% when 'video' %}
{{ media | video_tag: controls: true }}
{% when 'model' %}
{{ media | model_viewer_tag }}
{% else %}
{{ media | media_tag }}
{% endcase %} ``` Each media type in the example above is wrapped in a `
` element with custom `style` and data attributes. These are based on the considerations documented in [UX considerations](#ux-considerations), and should be adjusted accordingly to match your approach. Tip For another example of supporting media in a theme, you can refer to Dawn's implementation in the [`main-product.liquid` section](https://github.com/Shopify/dawn/blob/main/sections/main-product.liquid) and [`product-thumbnail.liquid` snippet](https://github.com/Shopify/dawn/blob/main/snippets/product-thumbnail.liquid). *** ## UX considerations Every theme requires a different approach to create responsive media that works across all screen sizes and devices. The following general recommendations can help ensure that you're offering a good customer experience: * [Make media elements responsive](#responsive-media-elements) * [Preserve media element interactivity](#interactive-media-elements) A product can have multiple videos, so if your theme has a thumbnail view for each media element, or displays multiple media elements at once, you should ensure that only the active video is playing. Tip For more in-depth information, refer to [Product media UX guidelines](https://shopify.dev/docs/storefronts/themes/product-merchandising/media/media-ux). ### Responsive media elements Shopify-hosted 3D models use [Google's model viewer](https://modelviewer.dev/) component, and externally rendered videos are rendered in `