Media fields in forms
Image, File, Gallery and Video fields work in forms the same way as on edit screens: they open the WordPress media library, where people upload or choose files.
Who gets media fields
The media library needs the upload_files capability (authors and up by
default). So:
- People with
upload_filessee media fields and the library. - People without it (subscribers, visitors) do not see media fields, and media values they send are ignored.
To let subscribers add images, give their role upload_files (for example
with a role editor plugin), then they can also use the media library.
What is checked
Attachment IDs from the browser are never trusted. Each submitted file must be:
- an existing attachment (not in the trash), and
- a file the user may see: public, or
read_postfor private files,
unless it is already saved in that field. Everything else is refused with "This file cannot be used here.", also inside Collections.
The field's own rules (allowed types, min/max size, dimensions, number of images) apply as on edit screens.
Front-end notes
- CAFE loads the media library scripts on pages with a form, only for people
with
upload_files. - Some themes hide or restyle the media modal; if the library looks broken,
check the theme's CSS for
.media-modal.