Skip to content

Media viewer ​

Shows a mediafile in the viewer that fits its type, under one shared toolbar.

base-mediaviewernew--defaultOpen in Storybook ↗

When to use ​

  • Mediafiles on a record's detail page, in a media panel or in the preview.
  • Whenever people need to look closely: zoom into an image, page through a PDF, play a recording.

When not to use ​

  • Thumbnails in lists and cards: show the image itself, not a viewer.
  • Actions on the mediafile record (edit, delete, link): those belong in the panel or the list row, not in the viewer toolbar.

Anatomy ​

  1. Toolbar: a white bar over the top of the viewer, --viewer-toolbar-height high, with a soft shadow. Viewer actions on the left, the file arrows in the middle when there are several files, mode actions on the right. Below 768px it moves to the bottom of the viewer and scrolls sideways when the buttons don't fit.
  2. Viewer buttons: icon buttons of --viewer-button-width by --viewer-button-height, with a --color-accent-wash hover on --viewer-button-radius. Text buttons such as Reset get --viewer-text-button-padding-x. A disabled button uses --color-text-disabled.
  3. Viewer: the file itself, on a checkerboard background.
  4. File arrows (optional): Previous file and Next file, when the record has more than one mediafile.

The viewer is picked from the file's type:

TypeViewer
imagedeep-zoom image viewer (OpenSeadragon, IIIF)
PDFpage-by-page PDF viewer
textthe text, sanitised, with adjustable size
audio, videothe browser's own player
external linkthe linked page in a frame, or a link to open it

Variants ​

The toolbar shows what the viewer can do:

ModeLeftRight
Imagefullscreen, zoom in, zoom out, rotate, crop tools (when cropping is on), download, recrop, Show original / Show croppedDownload resized image, Reset
PDFfullscreen, zoom in, zoom out, download‹ page number / count ›
Textzoom in, zoom out, download—
Audio, videodownload—
components-viewertoolbar--modesOpen in Storybook ↗
base-pdfviewer--defaultOpen in Storybook ↗
  • Image: drag to pan, scroll to zoom. Reset fits the image again. With cropping on, the crop button draws a selection and the clear button removes it; both are disabled with the tooltip Select an item first to enable this tool until a file is selected.
  • PDF: the arrows are disabled on the first and last page. A typed page number outside the document is corrected to the nearest page.
  • Text: the size goes from 50% to 300% in steps of 25%. When unsafe content was removed, a warning band under the toolbar says so (--color-warning-bg with a --viewer-banner-accent-width bar in --color-warning), with Dismiss.
base-textviewer--defaultOpen in Storybook ↗

States ​

StateWhat you seeTrigger
Loadinga spinnerthe file loads
ProcessingProcessing the image... with a crossed-out image iconthe image has no display version yet
Downloadinga spinner in place of the download buttondownload
No viewerThere is currently no viewer available for files with type '{mimetype}' and Download filea type without a viewer
No file typeNo viewer available for this filethe file has no type
External linka frame with the URL and Open link, or only Open linkthe mediafile is a link
base-mediaviewernew--unsupportedOpen in Storybook ↗

Keyboard & accessibility ​

  • The toolbar is a role="toolbar" named Viewer actions.
  • Every toolbar button is a real <button> with a name: Fullscreen, Zoom in, Zoom out, Rotate, Download file, Previous page, Next page. The page field is named Page number.
  • Entering fullscreen is announced: Fullscreen. Press Escape to exit. Escape leaves fullscreen.
  • Audio and video use the browser's controls, which are keyboard accessible.

Content ​

  • Button names are short verbs or nouns, the same in every viewer: Zoom in, Download file.
  • Translation keys live under media-viewer.*, plus tooltip.media-viewer.* for the crop tools and text-viewer.* for the warning band.

Map viewer · Preview panel · Upload · Loading

Powered by Elody - Open Source Semantic Data Platform