English (United Kingdom)

Displays a composite field to upload files.

type

(string)  Must be equals to file.

label

(string)  The label to display next to the field.

help

(string)  An optional text to describe the purpose of the field.

required

(bool)  Whether the field is mandatory or optional.

value

(string|array)  The last uploaded file(s).

id

(string)  An optional field ID.

class

(string)  An optional field class suffix.

hidden

(bool)  True to avoid displaying the label of the field.

multiple

(bool)  Whether the field supports the upload of multiple files (false by default).

files

(array[])  An array containing the details of the uploaded files.

  • name - the file name;
  • uri - the complete file URL.
[
    'gallery' => [
        'type' => 'file',
        'label' => 'Gallery',
        'value' => ['image-1.png', 'image-2.png'],
        'multiple' => true,
        'files' => [
            [
                'name' => 'image-1.png',
                'uri' => home_url('/wp-content/images/image-1.png'),
            ],
            [
                'name' => 'image-2.png',
                'uri' => home_url('/wp-content/images/image-2.png'),
            ],
        ],
    ]
]

Changelog

Version Description
1.2.5 Introduced.
Last Update: 2022-03-09
Helpful?
This site uses cookies. By continuing to browse you accept their use. Further information