<# if ( data.description ) { #>
{{{ data.description }}}
<# } #>
true,
'media_type' => 'image',
'dynamic' => [
'categories' => [ TagsModule::IMAGE_CATEGORY ],
'returnType' => 'object',
],
];
}
/**
* Get media control image title.
*
* Retrieve the `title` of the image selected by the media control.
*
* @since 1.0.0
* @access public
* @static
*
* @param array $attachment Media attachment.
*
* @return string Image title.
*/
public static function get_image_title( $attachment ) {
if ( empty( $attachment['id'] ) ) {
return '';
}
return get_the_title( $attachment['id'] );
}
/**
* Get media control image alt.
*
* Retrieve the `alt` value of the image selected by the media control.
*
* @since 1.0.0
* @access public
* @static
*
* @param array $instance Media attachment.
*
* @return string Image alt.
*/
public static function get_image_alt( $instance ) {
if ( empty( $instance['id'] ) ) {
return '';
}
$attachment_id = $instance['id'];
if ( ! $attachment_id ) {
return '';
}
$attachment = get_post( $attachment_id );
if ( ! $attachment ) {
return '';
}
$alt = get_post_meta( $attachment_id, '_wp_attachment_image_alt', true );
if ( ! $alt ) {
$alt = $attachment->post_excerpt;
if ( ! $alt ) {
$alt = $attachment->post_title;
}
}
return trim( strip_tags( $alt ) );
}
}