PhoenixKitWeb.Components.MediaViewer (phoenix_kit v1.7.112)

Copy Markdown View Source

Standalone image lightbox ("slide box") LiveComponent.

Renders a modal showing one image from an ordered set, with prev/next navigation (chevrons + ←/→ keys), Escape/backdrop close, and a Download link. Images render via <.image_set> (responsive <picture>).

Reusable on its own or embedded by MediaGallery.

Attrs

  • id — required
  • files — ordered list of file UUIDs (the navigable set)
  • current — initial UUID to show (must be in files). Treated as a seed: once the component is mounted, internal navigation state takes precedence over subsequent current attr changes. This is intentional when the component is mount-gated (:if={...}) so it remounts fresh on each open. A standalone consumer that keeps the component mounted and wants to jump to a different image programmatically must unmount and remount it.
  • variants_map — optional %{uuid => variants}; resolved internally if nil/omitted. Note: %{} (empty map) is truthy and counts as pre-resolved — pass nil or omit to trigger internal resolution.
  • file_structs — optional [%Storage.File{}]; resolved internally if nil/omitted. Note: [] (empty list) is truthy and counts as pre-resolved — pass nil or omit to trigger internal resolution.
  • notify — optional {module, id}; see Close below

Close

On close, if notify: {module, id} is set: send_update(module, id: id, media_viewer_closed: true). Otherwise: send(self(), {__MODULE__, id, :closed}).

Summary

Functions

render(assigns)

Callback implementation for Phoenix.LiveComponent.render/1.