Search documentation of phoenix_kit

# PhoenixKitWeb.Components.Core.MediaThumbnail (phoenix_kit v1.7.87)

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

resolve_url(file, size \\ :small)

Resolves the best thumbnail URL for a media file.

thumbnail_url(assigns)

Resolves the best thumbnail URL for a media file.

## Functions

# resolve_url(file, size \\ :small)

    @spec resolve_url(map(), :small | :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.

Two size modes:

- `:small` (default) — for selectors and grids: prefers thumbnail/small variants
- `: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` 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`, or `:medium`.

## Slots

- `inner_block` (required)