Media_Selector
in package
WP media selector functionality.
Provides the media selector HTML partial. Enqueues required resources. Sets default JS variables.
Tags
Table of Contents
Constants
- IMAGE_SIZE = 'medium_large'
- The image size to display in the media selector container.
- MEDIA_SELECTOR_CONTAINER = 'media-selector.php'
- Media selector partial filename.
Properties
- $instances : array<string|int, object>
- The array of instances of this class and sub-classes.
- $media : Media
- The instance of the Media class.
- $media_selector_container : string
- The fully qualified path to the media selector partial.
Methods
- get_instance() : object
- Creates and/or returns the instance of this class.
- render() : void
- Render the media selector.
- __construct() : void
- Initialise the class.
- enqueue_assets() : void
- Enqueue the media selector resources.
- get_inline_script() : string
- Get the inline javascript.
Constants
IMAGE_SIZE
The image size to display in the media selector container.
protected
string
IMAGE_SIZE
= 'medium_large'
This must be one of the defined images sizes.
Tags
MEDIA_SELECTOR_CONTAINER
Media selector partial filename.
protected
string
MEDIA_SELECTOR_CONTAINER
= 'media-selector.php'
Tags
Properties
$instances
The array of instances of this class and sub-classes.
protected
static array<string|int, object>
$instances
= array()
Tags
$media
The instance of the Media class.
protected
Media
$media
Tags
$media_selector_container
The fully qualified path to the media selector partial.
protected
string
$media_selector_container
= ''
Tags
Methods
get_instance()
Creates and/or returns the instance of this class.
public
static get_instance() : object
Tags
Return values
object —The instance of this class.
render()
Render the media selector.
public
render(array<string|int, mixed> $media_data) : void
Parameters
- $media_data : array<string|int, mixed>
-
{ The array of data for the media selector. @type int $image_id The id of the selected image. @type string $alt Optional. The alt text of the selected image. @type string $field_id Optional. The attribute for the field id tag. @type string $field_name The input field name. @type string $title_remove Optional. The text for the replace button. @type string $title_replace Optional. The text for the replace button. @type string $title_select Optional. The text for the select button. @type string $url Optional. The url of the selected image. }
Tags
__construct()
Initialise the class.
protected
__construct() : void
Tags
enqueue_assets()
Enqueue the media selector resources.
protected
enqueue_assets() : void
Tags
get_inline_script()
Get the inline javascript.
protected
get_inline_script() : string
Tags
Return values
string —The inline javascript.