IIIF Image API 3.0-specific Phoenix components.
<.image provider={:iiif}> covers the static-thumbnail case —
it emits a single <img> whose src is built by
Image.Components.URL.iiif/2. This module covers the IIIF
fundamentals that don't fit the cross-provider component shape:
:staticmode — same as<.image provider={:iiif}>, but lives here for symmetry with the other modes. Renders a single<img>.:tilesmode — emits a CSS grid of<img>tiles at a chosen scale factor. No JavaScript. Useful for high-resolution static layouts (atlases, scanned documents) where the tile structure of the IIIF source maps cleanly onto a fixed-size grid.:viewermode — emits a<div>carryingdata-iiif-info-url=…, ready for a JavaScript deep-zoom viewer (OpenSeadragon, Mirador, Leaflet-IIIF) to mount into. A static fallback<img>lives inside the div for the no-JS / loading-state case.
Use this module when your image source is IIIF-compliant and
you need tiling or viewer mounting. For thumbnails, use the
generic <.image provider={:iiif}> from Image.Components.
Usage
defmodule MyAppWeb.GalleryLive do
use MyAppWeb, :live_view
import Image.Components.IIIF
def render(assigns) do
~H"""
<%!-- Static thumbnail --%>
<.iiif src="/cat.jpg" host="https://iiif.example.org" width={400} />
<%!-- Tile grid for a 4096×4096 source at scale factor 2 --%>
<.iiif
src="/atlas.jpg"
host="https://iiif.example.org"
mode={:tiles}
source_width={4096}
source_height={4096}
tile_width={512}
scale_factor={2}
/>
<%!-- Deep-zoom viewer mount --%>
<.iiif
src="/portrait.jpg"
host="https://iiif.example.org"
mode={:viewer}
width={800}
height={600}
phx-hook="OpenSeadragon"
id="viewer-1"
/>
"""
end
endSee the IIIF guide for the per-mode walkthrough and the JavaScript-viewer wiring recipe.
Summary
Functions
Renders an IIIF image. See the moduledoc for mode descriptions.
Functions
Renders an IIIF image. See the moduledoc for mode descriptions.
Attributes
Common to all modes:
src— the IIIF identifier path. Required.host— the IIIF server's host (e.g."https://iiif.example.org"). Defaults to"".iiif_prefix— the server's IIIF version prefix segment. Defaults to"/iiif/3".mode—:static(default),:tiles, or:viewer.
Static mode uses every per-transform attribute that
Image.Components.image/1 accepts (width, height, fit,
region, iiif_quality, format, …) — see that component's docs.
Tile mode (mode={:tiles}):
source_width,source_height— the source image's pixel dimensions, required. (Discover them frominfo.jsonif you don't have them — the discovery step is out of scope here.)tile_width— pixel width of each rendered tile. Defaults to512(the IIIF Image API 3.0 default tile size). Pass the server's actualtiles[0].widthfrominfo.jsonfor tightest cache alignment with the server's pre-computed tiles.tile_height— defaults totile_width(square tiles).scale_factor— integer; the tiles covertile_width * scale_factorsource pixels each, rendered attile_width.1is full resolution. Higher = more pixels per tile, fewer tiles total. Defaults to1.format,iiif_quality— applied to every tile URL. Default:jpegand:default.
Viewer mode (mode={:viewer}):
width,height— pixel size of the viewer container. CSS pixels. Defaults to800×600.viewer— informational atom passed through asdata-iiif-viewer="…"so a JS hook can dispatch on viewer family. Defaults to:openseadragon. Other common values::mirador,:leaflet.fallback_size— width passed to the static fallback<img>inside the viewer div. Shown before JS mounts. Defaults to800.Any
phx-hook=…,id=…,class=…, or other HTML attributes pass through to the outer<div>via:rest.
Returns
- Renders an
<img>(static), a wrapper<div>containing a CSS grid of<img>tiles (tiles), or a wrapper<div>with viewer-mount data attributes plus a fallback<img>(viewer).
Attributes
src(:string) (required)host(:string) - Defaults to"".iiif_prefix(:string) - Defaults to"/iiif/3".mode(:atom) - Defaults to:static. Must be one of:static,:tiles, or:viewer.width(:integer) - Defaults tonil.height(:integer) - Defaults tonil.fit(:atom) - Defaults tonil.region(:any) - Defaults tonil.iiif_quality(:atom) - Defaults tonil.Must be one of:default,:color,:gray,:bitonal, ornil.format(:atom) - Defaults tonil.iiif_format(:atom) - Defaults to:jpeg.source_width(:integer) - Defaults tonil.source_height(:integer) - Defaults tonil.tile_width(:integer) - Defaults to512.tile_height(:integer) - Defaults tonil.scale_factor(:integer) - Defaults to1.viewer(:atom) - Defaults to:openseadragon.fallback_size(:integer) - Defaults to800.- Global attributes are accepted. Supports all globals plus:
["alt", "class", "id", "loading", "decoding", "fetchpriority", "phx-hook", "phx-update", "style"].