Skip to main content
Use the media_tag filter to turn an image or video value into complete HTML markup:
The filter accepts a URL string, a media value, or a hash with a url or src key. It returns an empty string for an empty input. Fluid renders a <video> when the media type is video or when the URL path ends in .mp4, .mov, .webm, or .m4v. Other inputs render as <img>.

Render responsive images

For an image on Fluid’s ImageKit host, the default output includes:
  • A srcset with widths 400, 800, 1200, and 1600
  • sizes="100vw"
  • ImageKit quality 80 and format auto
  • loading="lazy" and decoding="async"
  • An empty alt value unless the input supplies alt text
Use these options to control the result: When the input includes intrinsic dimensions, Fluid adds width and height attributes. It also caps the responsive width ladder at the intrinsic width. For a fixed-size image, pass width:
This creates 240w and 480w renditions and sets sizes="240px".
Do not add a w- token to transform. Use width or widths so the transformation stays aligned with srcset.

Render videos

ImageKit-hosted videos request MP4 output by default. Fluid also generates a poster URL from the first frame unless you supply poster.
The result includes autoplay, loop, muted, and playsinline. playsinline is added automatically when you enable muted or autoplay.

Handle external media and attributes

For media outside Fluid’s configured ImageKit host, the filter preserves the original URL. External images do not receive a transformed srcset. External videos do not receive an ImageKit format transformation or generated poster. Options such as class, id, style, data-*, and fetchpriority pass through as HTML attributes. Fluid escapes attribute values and removes every attribute whose name starts with on, such as onerror or onload. For direct URL transformations, see image transformations. For available theme data, see theme variables.