Skip to content

Media

TypeDescriptionStored as
fileMedia Library picker. args.multiple: true for multi-attachment.array of attachment IDs
ArgDefaultNotes
multiplefalseAllow 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.
[
'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'),
],
],
[
'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.