Media Tag
You get the HTML tag of a piece of media: an <iframe> for a video_url setting, or an <img> for an image URL.
liquid
{{ media | media_tag: option: value }}Options
| Option | Type | Description |
|---|---|---|
image_size | string | The width of the image, for example '800x'. Only used for images. |
autoplay, loop, controls, muted | boolean | Added to the video URL. Only used for videos. |
Every other option is added as an attribute of the tag, as with image_tag and external_video_tag.
Example
liquid
{{ product.images.first | media_tag: image_size: '800x', class: 'product-image' }}Output
html
<img src="https://cdn.youcan.shop/stores/acme/hat.png?width=800" alt="" srcset="https://cdn.youcan.shop/stores/acme/hat.png?width=352 352w, https://cdn.youcan.shop/stores/acme/hat.png?width=800 800w" width="800" class="product-image">