General

Media

A responsive image block component with optional lightbox functionality, customizable aspect ratios, and device-specific sizing controls.

Overview

Enables content editors to insert and manage responsive images within page layouts. Creates visually engaging content that adapts seamlessly across all device sizes. Display product images, hero banners, or editorial photography with consistent styling. Configure different sizing for mobile versus desktop to optimize visual presentation. Add captions and accessibility descriptions for improved user experience. Leverages Radix Vue Dialog for accessible lightbox implementation.

Key Business & UX Benefits

  • Delivers the right image size per device for fast load and good quality.
  • Engages users with lightbox zoom and pan for detailed viewing.
  • Gives editors control over aspect ratio and mobile vs desktop sizing.
  • Keeps images accessible with captions and descriptions.
Pro-Tip from Larry: Set separate mobile and desktop aspect ratios so images look great on every screen.

Usage

Uses nuxt-image to render responsive images. The component takes a Media value (the canonical discriminated union returned by connectors and produced by the media schema field) and reads its sources to pick the right variant for the current viewport.

Media

Feature List

  • Lightbox with zoom and pan using Radix Vue Dialog and Swiper
  • Cross-image navigation in lightbox across all enabled media on the page
  • Custom aspect ratios with separate mobile and desktop values
  • Fixed height option with responsive values that overrides aspect ratio

API Reference

PropDefaultType
mediatoMedia("/no-media-provided.svg", 1, 1)
altstring

Override default alt passed in media object.

aspectRatiostring | number | boolean

Aspect-ratio as string in format 4:3 or 4/3. It's also possible to pass a number. When passed true, the element will use the images original aspect-ratio if possible.

Note that true selects the first media source for calculation.

(Order of types has to stay as is, boolean first. Required for shorthand to work.)

sizesstring

Specify responsive sizes.

This is a space-separated list of screen size/width pairs. Uses laioutr-ui breakpoints.

retinafalseboolean

Pass true to enable retina (2x density) images.

Disabled by default.

widthstring | number

Specify width of the image

heightstring | number

Specify height of the image

loading"lazy" | "eager"

This is a native attribute that provides a hint to the browser on how to handle the loading of an image which is outside the viewport.

Defaults to 'lazy' for performance reasons.

preloadfalseboolean

In case you want to preload the image, use this prop. This will place a corresponding link tag in the page's head.

fetchpriority"auto" | "low" | "high"

This is a native attribute that provides a hint to the browser on how to prioritize the loading of an image.

This value is also used for the link header tag, when preload is used.

desktopBreakpointmd

Specify the breakpoint at which the image should be displayed as a desktop image. Can be either a pre-defined breakpoint key (like 'lg') or a number (width in pixels).

Copyright © 2026 Laioutr GmbH