Skip to main content
Glama
media.md1.58 kB
# Media Object ## Overview The `media` object serves as an abstract representation for multiple media types within Shopify's Liquid templating language. It can encapsulate: - `image` - `model` - `video` - `external_video` This object appears in the `product.media` array or within `file_reference` metafields. ## Usage Developers can leverage "[media filters](https://shopify.dev/docs/api/liquid/filters/media-filters)" to generate URLs and displays. For comprehensive guidance on implementing media in themes, consult the documentation on supporting product media. **Note:** Each media type includes unique properties beyond the standard media attributes. ## Properties | Property | Type | Description | |----------|------|-------------| | `alt` | string | Descriptive text for the media | | `id` | number | Unique identifier | | `media_type` | string | Type classification (image, model, video, or external_video) | | `position` | number | Index within the product.media array; returns nil for file_reference metafields | | `preview_image` | image | Thumbnail representation (lacks ID attribute) | ## Example Implementation Filter media by type using the `where` filter to isolate specific formats from the product.media collection: ```liquid {% assign images = product.media | where: 'media_type', 'image' %} {% for image in images %} {{- image | image_url: width: 300 | image_tag }} {% endfor %} ``` ## Sample Data Structure ```json { "alt": "Dandelion milk", "id": 21772527435841, "media_type": "image", "position": 1, "preview_image": {} } ```

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/florinel-chis/shopify-liquid-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server