Skip to content

File Field

One file, picked from a MODX media source.

Settings:

SettingWhat it does
SourceWhich media source to upload into and pick from
File pathFolder inside that source

The path understands four placeholders, so every object can keep its files apart:

PlaceholderBecomes
{resource_id}Id of the object the field belongs to
{id}Id of the record
{user_id}Id of the user doing the upload
{alias}The object's alias

So uploads/{resource_id}/ puts each page's files in a folder of its own.

Output — the value is a set of facts about the file:

html
<a href="/{$file.url}" download>{$file.title} ({$file.size} bytes)</a>

Available keys: url, path, filename, name, extension, title, size, type, and width / height for images.

type tells you what you got

It holds image, video, audio or the extension. Handy when the field may receive a PDF as easily as a picture and the markup has to differ.

© PageBlocks 2019-present