Plugins
Document Preview

Configuration

Every document-preview option.

documentPreview({
  collections: {
    [uploadSlug]: true | {
      display?: 'drawer' | 'inline' | 'both' // default 'drawer'
      listView?: boolean                     // default false
      fileIcons?: boolean                    // default: the global fileIcons
      filesizeCell?: boolean                 // default true
      viewers?: { [mimePattern: string]: string }
    },
  },
  viewers?: { [mimePattern: string]: string }
  fileIcons?: boolean | {                    // default true
    types?: { [mimePattern: string]: { label: string; color: string } | { svg: string } }
  }
  disabled?: boolean
  translations?: TranslationsOption
})

Plugin

OptionDefault
collectionsrequiredThe upload collections that get previews. true takes the defaults; an object customizes. A slug that does not exist, or is not an upload collection, is a config error.
viewers{}Viewer components for every enabled collection, by mime pattern. See custom viewers.
fileIconstrueThe default for every collection's fileIcons. An object turns icons on and adds your own types. See file icons.
disabledfalseReturn the config untouched, for opting out per environment.
translations{}Per-locale overrides for the admin strings. See i18n.

Per collection

OptionDefault
display'drawer''drawer': a Preview button beside the document controls. 'inline': the preview above the fields. 'both'. See surfaces.
listViewfalseA Preview column in the list view.
fileIconsthe global fileIconsFile-type icons for this collection's non-image thumbnails.
filesizeCelltrueShow filesize as 1.2 MB in the list view. A Cell the collection sets on filesize itself is kept.
viewers{}Viewer components for this collection only, checked before the global viewers.

Mime patterns are lowercase: an exact mime (video/mp4) or a type wildcard (video/*). A malformed pattern is a config error.

Fields the plugin adds

FieldWhen
documentPreviewdisplay is 'inline' or 'both'UI field, first in the collection. Stores nothing.
documentPreviewColumnlistViewUI field, last in the collection, carrying the list cell. Stores nothing.
filesizefilesizeCellOnly an admin Cell, merged into Payload's upload field.
thumbnailURLfileIconsOnly an afterRead hook, merged into Payload's upload field.

None of them adds a column to the database. A collection that already has a field named documentPreview or documentPreviewColumn is a config error.

Exports

Path
@10x-media/document-previewdocumentPreview and the option types
@10x-media/document-preview/clientDocumentPreview, PreviewDrawer, DocumentPreviewProvider, the admin components the plugin registers
@10x-media/document-preview/rscDocumentPreviewProviderServer, the admin-wide provider the plugin registers
@10x-media/document-preview/typesDocumentPreviewViewerProps, DocumentPreviewViewer, the option and icon types
@10x-media/document-preview/i18nkeys, translations

On this page