Arguments
Name | Type | Default | Description |
---|
id | string | | A unique ID. This ID will be used to get the value |
type | string | media | Type of the field |
title | string | | Title of the field |
default | array | | Default value from database, if the option doesn’t exist |
subtitle | string | | Subtitle to display below the title. |
desc | string | | Description to display after the field |
help | string | | Text to display on right-corner (as hover/popup) of the field |
class | string | | Extra CSS classes (space separated) to append to the field |
before | string | | Content to display before the field |
after | string | | Content to display after the field |
dependency | array | | Define field visibility depending on other field value |
attributes | array | | Extra HTML attributes to append to the field |
sanitize | string | | Callback function for sanitizing value |
validate | string | | Callback function for validating value |
EXTRAS | | | |
url | bool | true | Flag to display url of the field |
preview | bool | true | Flag to display preview of the field |
library | array|string | all | Tell the modal to show specific formats. for ( image or video or both ) |
placeholder | string | No media selected | The placeholder to be displayed when nothing is selected |
preview_size | string | thumbnail | The image size to use in preview (thumbnail or full ) |
button_title | string | Upload | Text to display on the upload button |
remove_title | string | Remove | Text to display on the remove button |
Default Arguments
Name | Type | Description |
---|
url | string | String representing the default URL of the attachment. |
id | number | Numberic representing the default attachment ID |
width | number | String representing the default image width value |
height | number | String representing the default image height value |
thumbnail | string | String representing the default image thumbnail |
alt | string | String representing the default alt value |
title | string | String representing the default title value |
description | string | String representing the default description value |
Simple Media Field Example
array(
'id' => 'example-media',
'type' => 'media',
'title' => 'Media',
),
Media Field Example without Preview
array(
'id' => 'example-media',
'type' => 'media',
'title' => 'Media',
'preview' => false,
),
Media Field Example using only Image Formats
array(
'id' => 'example-media',
'type' => 'media',
'title' => 'Media',
'library' => 'image',
),
Was this article helpful to you?
Yes
No