Media
in package
Provides enhanced media functionality.
- Provides a default image.
- Provides image attribute data.
Tags
Table of Contents
Constants
- FEATURED_IMAGE_DEFAULTS = array('post_id' => 0, 'image_size' => 'big_prop')
- Featured image url defaults.
- IMAGE_ATTRIBUTE_DEFAULTS = array('id' => 0, 'url' => '', 'alt' => '', 'caption' => '', 'description' => '', 'title' => '', 'srcset' => '', 'sizes' => '')
- Image attribute defaults.
Properties
- $fallback_image_id : int
- Default fallback image ID.
- $instances : array<string|int, object>
- The array of instances of this class and sub-classes.
Methods
- get_fallback_image_id() : int
- Get fallback image ID.
- get_fallback_image_url() : string
- Get fallback image url.
- get_featured_image_url() : string
- Return the featured image url.
- get_image_attributes() : array<string|int, mixed>
- Get image attributes.
- get_instance() : object
- Creates and/or returns the instance of this class.
- __construct() : void
- Initialise the class.
Constants
FEATURED_IMAGE_DEFAULTS
Featured image url defaults.
protected
array<string|int, mixed>
FEATURED_IMAGE_DEFAULTS
= array('post_id' => 0, 'image_size' => 'big_prop')
{ The defaults to use to retrieve featured image url. @type int $post_id The post id to search for featured image. @type string $image_size The default image size. }
Tags
IMAGE_ATTRIBUTE_DEFAULTS
Image attribute defaults.
protected
array<string|int, mixed>
IMAGE_ATTRIBUTE_DEFAULTS
= array('id' => 0, 'url' => '', 'alt' => '', 'caption' => '', 'description' => '', 'title' => '', 'srcset' => '', 'sizes' => '')
{ The defaults to use for retrieved image attributes. @type int $id The attachment id. @type string $url The attachment permalink. @type string $alt The attachment alt text. @type string $caption The attachment caption. @type string $description The attachment description. @type string $title The attachment title attribute. @type string $srcset The attachment srcset attribute. @type string $sizes The attachment sizes attribute. }
Tags
Properties
$fallback_image_id
Default fallback image ID.
protected
int
$fallback_image_id
= 0
Tags
$instances
The array of instances of this class and sub-classes.
protected
static array<string|int, object>
$instances
= array()
Tags
Methods
get_fallback_image_id()
Get fallback image ID.
public
get_fallback_image_id() : int
Tags
Return values
int —Attachment ID, otherwise false.
get_fallback_image_url()
Get fallback image url.
public
get_fallback_image_url() : string
Tags
Return values
string —The attachement url
get_featured_image_url()
Return the featured image url.
public
get_featured_image_url([array<string|int, mixed> $args = array() ]) : string
Parameters
- $args : array<string|int, mixed> = array()
-
The featured image url arguments.
Tags
Return values
string —The featured image url.
get_image_attributes()
Get image attributes.
public
get_image_attributes(int $image_id[, string $image_size = 'medium' ]) : array<string|int, mixed>
Parameters
- $image_id : int
-
Attachment ID.
- $image_size : string = 'medium'
-
Optional. Image size.
Tags
Return values
array<string|int, mixed> —Array of image attributes.
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.
__construct()
Initialise the class.
protected
__construct() : void