Media
| Type | Description | Stored as |
|---|---|---|
file | Media Library picker. args.multiple: true for multi-attachment. | array of attachment IDs |
| Arg | Default | Notes |
|---|---|---|
multiple | false | Allow picking multiple attachments. |
mime_types | '' | Filter to a MIME type — 'image', 'video', 'application/pdf', etc. |
media_title | 'Select media' | Title of the media-library modal. |
media_button | 'Use selection' | Label of the confirm button inside the modal. |
Example — single image
Section titled “Example — single image”[ 'id' => 'logo', 'type' => 'file', 'label' => __('Logo', 'my-plugin'), 'columns' => 6, 'args' => [ 'mime_types' => 'image', 'media_title' => __('Choose a logo', 'my-plugin'), 'media_button' => __('Use image', 'my-plugin'), ],],Example — multiple files
Section titled “Example — multiple files”[ 'id' => 'gallery', 'type' => 'file', 'label' => __('Gallery', 'my-plugin'), 'args' => [ 'multiple' => true, 'mime_types' => 'image', ],],Opening the picker pre-selects the attachments already stored on the field, so you can deselect or add to them without re-picking from scratch.