Skip to main content

molecules

Media figure

One image, picture, or video in a figure with an optional caption and an optional lightbox zoom.

Specimens

Image with caption
james-zabiela_3
The PHOTOS page — gallery navigation with a facebook link. Little text recovered; the page is its images. The site's navigation is consistent and short: news · tour · links · contact · shop · downloads · photos · video — with an email-capture field in the header on every page.
{{ Media.render({
  loading: "lazy",
  styles: {
    image: "block w-full",
    caption: "mt-2 text-sm text-neutral-400"
  },
  image: (collections.projectPages | filterByKey("slug", "connecting-a-world-famous-dj-with-his-fans") | first).decisions.0.artifact
}) }}
Zoomable image The zoom wraps the image in a button and adds a closed dialog. It opens only with the lightbox script.
james-zabiela_6
The archive's most interesting screen: unedited tweets as primary site content. "news · shop · photos · a random tweets", then a post dated 23 Mar 09, verbatim and unpolished — "I am trying to look like a pirate with this private plane in brazil but I was actually popping my pants" with a twitpic link. 185 words, the densest recovery here. A DJ's site publishing his own typos in 2009, which is a real editorial position about authenticity rather than an oversight.
The archive's most interesting screen: unedited tweets as primary site content. "news · shop · photos · a random tweets", then a post dated 23 Mar 09, verbatim and unpolished — "I am trying to look like a pirate with this private plane in brazil but I was actually popping my pants" with a twitpic link. 185 words, the densest recovery here. A DJ's site publishing his own typos in 2009, which is a real editorial position about authenticity rather than an oversight.
{{ Media.render({
  zoom: true,
  loading: "lazy",
  styles: { image: "block w-full" },
  image: (collections.projectPages | filterByKey("slug", "connecting-a-world-famous-dj-with-his-fans") | first).decisions.1.artifact
}) }}
Video Video wins over picture and image. Without zoom it shows controls.
{{ Media.render({
  alt: "Project screen capture",
  styles: { image: "block w-full" },
  video: {
    src: (collections.projects | filterByKey("slug", "connecting-a-world-famous-dj-with-his-fans") | first).featuredVideo.url
  }
}) }}

Params

ParamTypeDescription
imageobjectSanity image: asset.url, asset.metadata.dimensions, alt, and caption. The only source that gets width and height.
picturestringPre-rendered <picture> or <img> HTML. Wins over image. Carries its own alt.
videoobjectsrc and poster. Wins over picture and image. Only used when src is set.
altstringFallback for image.alt. The only alt for picture and video.
captionstringFallback for image.caption. Renders a <figcaption>.
classesstring, variant map, or arrayApplied to the <figure> through classes.
stylesobjectSlot map. See the slot table.
zoombooleanWraps the media in the lightbox trigger (data-lightbox-el) and renders the dialog from lightbox-dialog.njk.
loadingstringloading attribute on the <img> only. Defaults to eager.
attrsstringRaw attributes added to the <figure>.
overlaystringPre-rendered decorative HTML (aria-hidden, absolutely positioned) output last inside the <figure>. The caller positions the figure.
SlotElement
imageThe media element: <video>, the <span> around picture, or <img>.
captionThe <figcaption>.

Notes

Only an image gets intrinsic width and height. The figure renders nothing when it has no media. No styles are hard-coded, so pass styles.image and styles.caption.