Docs MediaHub Version 1.x Preview Covers

Preview Covers

Show preview images for PDFs, audio, and other non-image assets in the library, picker, and inputfield. Auto-generate when your server supports it, or choose a library image as a manual cover.

From MediaHub 1.19.51, PDFs, audio files, and other non-image assets can show a preview image in the library, picker, and inputfield instead of a generic file-type icon. One library item per file: generated previews and curated covers stay on the same asset page.

Images continue to use ProcessWire's normal Pageimage thumbnails. Preview covers apply to non-image assets and to optional custom posters on YouTube and Vimeo embeds.

Why previews are separate from the image field

MediaHub stores previews in dedicated fields, not in pkd_mediahub_image:

FieldRole
pkd_mediahub_filePrimary file for non-image assets (PDF, MP3, MP4, etc.)
pkd_mediahub_imagePrimary file for image assets only
pkd_mediahub_previewAuto-generated preview poster stored on the asset
pkd_mediahub_preview_refPage ID of a library image or crop used as a curated preview

Keeping previews out of the image field preserves correct isImage() behaviour and prevents crop and focus UI from appearing on poster images.

What editors see

Library, picker, and inputfield

  • Non-image asset with a preview: tile shows the cover image. Type badge (PDF, MP3, etc.) still appears.
  • Non-image asset without a preview: file-type icon (unchanged behaviour).
  • The asset does not appear under the Images filter. MIME type still drives filtering.

Asset detail page

Asset typeMain preview area
ImageFull image (+ transparency grid toggle)
Uploaded videoNative <video controls> when the browser can decode the file
AudioCover image (if set) above native <audio controls>
PDF / document with coverCover image + Open / Download links
No coverFile icon + download fallback
YouTube / Vimeo embedEmbedded player with click-to-play consent; optional custom poster

Preview image sidebar (non-image assets)

Under Asset Internal Notes on the asset detail page:

  • Click the preview thumbnail or + placeholder to choose an image or crop from the library
  • Clear the current preview with the × on the thumbnail strip
  • Status shows whether the cover is auto-generated or a library selection

Library selections save immediately. Removal uses the asset detail form save.

Automatic generation

When your server supports it, MediaHub generates a preview on upload or import. Orchestration runs after upload and after asset detail saves for non-image assets that do not have a library-selected preview.

Asset typeServer toolsResult
PDF (application/pdf)Imagick PHP extension, Poppler (pdftoppm), or Ghostscript (gs)First page rasterised to a JPEG on the asset
Audio (audio/*)ffmpeg (preferred) or embedded MP3 ID3 APIC artworkArtwork stored on the audio asset

Embedded MP3 artwork stays on the audio asset. It is not imported as a separate library image.

Auto-generation applies to uploaded non-image files only. YouTube and Vimeo embed imports always show a provider thumbnail from the CDN; see YouTube and Vimeo Embeds for custom poster overrides.

Library-selected previews are never overwritten by auto-generation.

Manual override (shared hosting workflow)

When PDF tools are unavailable on your host:

  1. Upload the PDF to MediaHub (stores in pkd_mediahub_file).
  2. Auto-generation fails silently; no preview is populated.
  3. Upload or pick an existing image or crop in the library.
  4. Open the PDF asset detail → Preview image → choose that library item.
  5. The library tile for the PDF now shows your chosen art.

No Imagick, Poppler, or Ghostscript required for this path.

Module settings

Go to Modules → Configure → MediaHub → Preview covers. Capability badges beside each toggle show what your server supports.

SettingDefaultPurpose
Generate PDF previewOnRasterise page 1 on upload/import
Generate audio previewOnExtract embedded artwork on upload/import
Max preview width1200 pxMaximum width of generated preview images

A short summary of these settings also appears on the Configuration page.

Template API

Methods on PkdMediahubAssetPage:

MethodReturnsDescription
$asset->preview()Pageimage|nullAuto-generated or stored preview file
$asset->hasPreview()boolWhether any preview exists
$asset->thumbSource()Pageimage|nullBest source for library-style thumbs: primary image, then preview ref, then auto preview

Thumbnail resolution order used internally:

  1. pkd_mediahub_image (real images)
  2. pkd_mediahub_preview_ref (library image or crop selected as curated preview)
  3. pkd_mediahub_preview (auto-generated preview for non-image assets)
foreach ($page->resources as $asset) {
if ($asset->isImage()) {
echo $asset->imgTag(400, 0);
continue;
}
$thumb = $asset->thumbSource();
if ($thumb) {
echo '<img src="' . $thumb->url . '" alt="' . htmlspecialchars($asset->title) . '">';
}
// file link, etc.
}

See Template API and findRaw for high-volume read paths.

What preview covers are not

  • Not a duplicate library item. Curated previews reference an existing image or crop, or store a derivative on the same asset page.
  • Not crop/focus eligible. Previews are posters, not master images.
  • Not the Images filter. Filtering still uses MIME type.
  • Not inline PDF embeds in TinyMCE. PDFs in rich text remain download links unless you add separate embed markup in your templates.

See also

Last updated