Field Automation
Optional per-field behaviours that pre-generate image size variations, file assets into collections, and apply library labels on upload and page save. Off by default until you opt in.
From MediaHub 1.20.0, optional field automation behaviours can run when editors upload into, or save a page holding, a MediaHub field. They reduce manual library housekeeping and front-end cold-cache resizing without changing how assets are stored or counted in the library.
All automation is off by default. Nothing runs until you enable it in module settings and configure the relevant field. Existing sites are unaffected until you opt in.
What you can automate
| Behaviour | When it runs | What it does |
|---|---|---|
| Pre-generated size variations | On upload and on page save | Generates a configured list of ProcessWire image size variations on disk so the first front-end request is cache-hot |
| Automatic collection filing | On page save | Files field assets into a target collection path, creating missing collections as needed |
| Automatic labelling | On page save | Applies configured library labels to field assets, creating missing labels as needed |
| Slow-save overlay | During page save | Shows a brief loading overlay in the page editor when automation makes a save take a moment |
Collection filing and labelling are additive: an asset is never removed from a collection or stripped of a label automatically. A label whose placeholder resolves to empty is skipped while the others still apply.
Why the Library matters
Field automation is built around MediaHub's page-per-asset model. When an upload enters the Library, it becomes a ProcessWire page with hooks, fields, and an automation layer that field settings can target directly.
You could approximate pieces of this with custom ProcessWire hooks on ordinary image fields. The difference is scope and integration. A plain page-field image is tied to the content page that holds it, not to a shared library asset with collections, labels, and cross-page reuse. MediaHub input fields are designed for that library model from the start: each field can carry its own automation rules (pre-generated sizes, collection paths, labels) without a separate integration project per template.
That adaptability is the point. Enable automation on the MediaHub fields that need it, configure different paths and sizes per field, and leave other fields unchanged. The library stays organised as editors upload and save, using the holding page's own fields to drive where assets land.
Example workflows
These are illustrative paths. Placeholders use field names from the holding page; missing collections and labels are created on save.
| Site type | Field | Collection path |
|---|---|---|
| News / publishing | Article gallery | /news/{category.title}/{date:Y-m}/ |
| Luxury hotel | Event gallery | /events/{event_type}/{date:Y-m}/ |
| Luxury hotel | Room gallery | /rooms/{room_type}/ |
| Luxury hotel | Documents (PDFs) | /documents/{department}/ |
| Photographer | Project gallery | /clients/{client_name}/{shoot_date:Y-m-d}/ |
| Heritage / museum | Event gallery | /events/{title}/ |
| Heritage / museum | Publications (PDFs) | /documents/{category}/ |
| Case studies / B2B | Downloads | /case-studies/{sector}/{date:Y}/ |
Collections created on save
Missing folders along each path are created automatically. Each example below shows the field configuration first, then collections that might appear after pages save.
News. Article gallery at /news/{category.title}/{date:Y-m}/ might create:
/news/Local News/2026-08/,/news/Business/2026-07/,/news/Sport/2026-03/
Luxury hotel. An event_gallery field at /events/{event_type}/{date:Y-m}/; room galleries at /rooms/{room_type}/; offer assets at /offers/{season}/; documents at /documents/{department}/. On save, that might create:
/events/Wedding/2026-06/,/events/Conference/2026-09/,/events/Seasonal Dinner/2026-12//rooms/Deluxe Suite/,/rooms/Garden Room//offers/Summer 2026/,/offers/Winter 2026//documents/F&B/,/documents/Events/
Photographer. Project gallery at /clients/{client_name}/{shoot_date:Y-m-d}/, or /portfolio/{genre}/{title}/ for personal work. For example:
/clients/Acme Corp/2026-08-15/,/clients/Northside Hotel/2026-05-03//portfolio/Editorial/Autumn lookbook/
Heritage / museum. News gallery at /news/{date:Y-m}/; event gallery at /events/{title}/; project photos at /projects/{project_name}/; publications at /documents/{category}/. That might produce:
/news/2026-08/,/events/Summer open day/,/projects/Station restoration//documents/Magazine/,/documents/Flyers/
Case studies / B2B. Downloads field filing into /case-studies/{sector}/{date:Y}/ (images and PDFs together). For example:
/case-studies/Retail/2026/,/case-studies/Healthcare/2026/,/case-studies/Manufacturing/2025/
Pair collection paths with automatic labelling (e.g. {sector}, {date:Y}, static PDF) and pre-generated size variations on image-heavy fields for cache-hot front-end output.
Enable field automation
- Go to Modules → Configure → MediaHub.
- Open the Field automation section.
- Tick Enable field automation and save.
- Configure each behaviour on the MediaHub fields where you want it (see below).
Until the module-level toggle is on, per-field settings have no effect.
Pre-generated size variations
ProcessWire normally creates resized image variations lazily on the first $image->size() call. On a busy gallery that can mean the first visitor pays the resize cost. Pre-generated variations warm those files up front on upload and on page save.
Important: These are ordinary ProcessWire image variations written to the asset's files directory, exactly what $image->size() produces. They are not separate library items: they do not appear in the library grid, do not increase the asset count, and are not stored as extra database pages.
Configure on a field
Setup → Fields → [field] → Input → Media Hub Picker Settings → Pre-generated size variations
Enter one size per line. Supported formats match ProcessWire's size syntax, for example:
400
800
1200x800
400x0
Variations generate on direct field upload and when the holding page is saved. A per-request limit prevents large galleries from hitting PHP's execution-time cap; remaining sizes continue on the next save or upload batch.
Read variations in templates
Pair with findRaw() and the opt-in variations field to read URLs and dimensions without generating sizes at render time. See findRaw.
Automatic collection filing
When an editor saves a page, assets in the configured field are filed into a target collection. Missing collections along the path are created automatically.
Configure on a field
Setup → Fields → [field] → Input → Media Hub Picker Settings → Automatic collection filing
Enter a collection path. Static example:
/news/images/
Dynamic path built from the page's own fields:
/news/{title}/{date:Y-m}/
Placeholders use field names from the holding page. Date fields support a format suffix after a colon (same idea as PHP date formatting).
Filing runs on page save, not on upload alone. Assets already in other collections stay there; the automation only adds membership.
Automatic labelling
When an editor saves a page, configured library labels are applied to assets in the field. Missing labels are created automatically.
Configure on a field
Setup → Fields → [field] → Input → Media Hub Picker Settings → Automatic labelling
Enter one label per line. Static example:
Press release
2026
Dynamic label from a page field:
{category.title}
If a placeholder resolves to empty, that label line is skipped. Other labels on the same line still apply.
Slow-save overlay
When field automation makes a page save take a moment (for example, generating many size variations across a large gallery), a brief loading overlay appears in the page editor so the delay does not look like a broken save. Fast saves never flash it.
Enable or disable under Modules → Configure → MediaHub → Field automation → Show slow-save overlay.
Relationship to upload automation
Module config Upload Automation (auto-generate crop presets on library upload) is separate from field automation. Crop presets create library crop pages. Pre-generated size variations create ordinary ProcessWire file variations. You can use either, both, or neither.
See also
- findRaw — read pre-generated variations with the
variationsopt-in field - Folders — how collections are organised in the library
- Labels — library labels vs per-reference display tags
- Adding to Templates — field settings overview
- Configuration — module-level toggles
Last updated