PhoenixKitWeb.Components.Core.MediaThumbnail (phoenix_kit v1.7.170)

Copy Markdown View Source

Provides a component for resolving and rendering media file thumbnail URLs.

Handles file type detection (image, video, PDF, document) and selects the appropriate thumbnail variant from the file's URL map.

Summary

Functions

Resolves the best thumbnail URL for a media file.

Resolves the best thumbnail URL for a media file.

Functions

resolve_url(file, size \\ :small)

@spec resolve_url(map(), :small | :card | :medium) :: String.t() | nil

Resolves the best thumbnail URL for a media file.

Returns nil when no suitable URL is available.

Examples

resolve_url(file)           # small thumbnail
resolve_url(file, :medium)  # medium preview

thumbnail_url(assigns)

Resolves the best thumbnail URL for a media file.

Size modes:

  • :small (default) — tiny cells (list rows, selectors): prefers the baked Etcher thumbnail, then the 150px thumbnail
  • :card — large grid/stack cards: prefers the baked Etcher thumbnail (400px), then the 300px small, then medium; only after those falls back to the light 150px thumbnail, keeping the full-res original (which would force a live vector overlay) as the last resort
  • :medium — for gallery/preview: prefers medium/thumbnail variants

Attributes

  • file - Media file map with file_type and urls fields (required)
  • size - Thumbnail size preference: :small, :card, or :medium (default: :small)

Examples

<.thumbnail_url file={file} :let={url}>
  <img src={url} />
</.thumbnail_url>

<.thumbnail_url file={file} size={:medium} :let={url}>
  <img src={url} />
</.thumbnail_url>

Attributes

  • file (:map) (required)
  • size (:atom) - Defaults to :small. Must be one of :small, :card, or :medium.

Slots

  • inner_block (required)