Per-Reference Metadata
Each selected asset can carry page-level metadata (a description override and display tags) stored separately from the global asset record. The same image can have a different caption depending on where it appears.
The concept
MediaHub's centralised model means an asset's alt text, title, and tags are set once and used everywhere. That's usually what you want: consistency without repetition.
But sometimes the same image needs different context on different pages. A photo of your office might appear on the About page with the caption "Our London headquarters" and on a blog post with "Where the magic happens." The image is the same; the description is page-specific.
Per-reference metadata solves this. Each time an asset is selected into a MediaHub field, it can carry its own description override and display tags, stored separately from the global asset record and scoped to that specific page and field.
Setting up
Metadata is stored automatically in a dedicated database table. No companion ProcessWire fields are required; the module handles everything.
To enable display tags on a field:
- Open the page reference field in Setup → Fields
- Go to the Input tab → File Tags section
- Choose a tag mode:
- Tags disabled: description overrides are still available to editors; tags are not shown
- User enters tags by text input: free-form tag entry
- User selects from list of predefined tags: editors pick from a fixed list
- User selects from predefined tags + can input their own: combined mode
- If using predefined tags (modes 2 or 3), enter a space-separated list in the Predefined tags field (e.g.
hero xray diagram) - Save the field
No other configuration is needed.
What editors see
When an asset is selected into a field with metadata enabled, the editor can click on the asset card to expand a metadata panel. This shows:
- Description: a text field for the page-specific caption or description
- Tags: depending on the field's tag mode, a text input, dropdown/checkboxes, or both
If the editor leaves the description blank, template code falls back to the asset's global alt text. If they enter a description, it overrides the global value for this specific usage.
Template API
Any multi-value field using the Media Hub Picker inputfield always returns a MediaHubPageArray, regardless of whether the File Tags option is enabled. The extra methods are always available; they just return empty values when no overrides have been saved.
Getting the description
// Per-page description: returns the page-level override,
// or falls back to the asset's alt text if no override exists
$caption = $page->gallery->description($asset);
// Use it in output
foreach ($page->gallery as $asset) {
$desc = $page->gallery->description($asset);
echo "<img src='{$asset->image()->url}' alt='{$desc}'>";
}
Working with display tags
// Get the first asset with a specific tag on this page
$hero = $page->gallery->getTag('hero');
// Get all assets with a specific tag (returns PageArray)
$diagrams = $page->gallery->findTag('diagram');
// Get all tags for a specific asset as an array of strings
$tags = $page->gallery->getDisplayTags($asset);
// e.g. ['hero', 'featured']
// Check if an asset has a specific tag
if ($page->gallery->hasDisplayTag($asset, 'hero')) {
// ...
}
Direct asset API
You can also look up the per-reference description directly from an asset page, without going through the field:
// Auto-detects the first MediaHub field on the page
$caption = $asset->descriptionFor($page);
// Explicit field name
$caption = $asset->descriptionFor($page, 'gallery');
Display tags vs library tags
These are two completely separate systems:
| Library tags | Display tags | |
|---|---|---|
| Where set | Asset detail page in Media Hub admin | Page editor, per field reference |
| Scope | Global: same on all pages | Per-reference: unique to each page/field |
| Purpose | Organisation: filtering library, categorisation | Output: controlling front-end display |
| API | $asset->tags(), $asset->hasTag() | $field->getTag(), $field->findTag() |
A common pattern is to use library tags for admin organisation (e.g. "Needs review", "Stock photo") and display tags for front-end logic (e.g. "hero", "thumbnail", "print-only").