Media
Select media using the default WP media popup.
Value
detailed => false
Returns (string)
$image_url = fx_get_meta('id');
detailed => true
Returns ImageObject
$image = json_decode(fx_get_meta('id'), true);
$image_description = $image['description'];
$image_id = $image['id'];
$image_name = $image['name'];
$image_title = $image['title'];
$image_url = $image['url'];
multiple => true
Returns (string|ImageObject)[]
$images = json_decode(fx_get_meta('id'), true);
foreach($images as $image) {
// If detailed = true
$image_url = $image;
// If detailed = false
$image_description = $image['description'];
$image_id = $image['id'];
$image_name = $image['name'];
$image_title = $image['title'];
$image_url = $image['url'];
}
Example
'id' => [
'type' => 'media',
'allowDuplicates' => false,
'className' => 'my-class-name',
'detailed' => true,
'multiple' => true,
'title' => 'Gallery',
'buttonText' => 'Add gallery image',
],
Props
allowDuplicates
Allow the same attachment multiple times
type: bool
defaultValue: false
buttonText
Alternate text for the add media button
type: string
defaultValue: 'Add media'
className
Metabox class name
type: string
detailed
Enable detail editing for attachments
type: bool
defaultValue: false
multiple
Enable multiple attachment selections
type: bool
defaultValue: false
title
Metabox title
type: string