WC_Meta_Box_Product_Images::get_video_preview_html
Get HTML preview for a video attachment.
Method of the class: WC_Meta_Box_Product_Images{}
No Hooks.
Returns
string.
Usage
$result = WC_Meta_Box_Product_Images::get_video_preview_html( $attachment_id );
- $attachment_id(int) (required)
- Attachment ID.
WC_Meta_Box_Product_Images::get_video_preview_html() WC Meta Box Product Images::get video preview html code WC 11.1.2
private static function get_video_preview_html( $attachment_id ) {
$poster_id = get_post_thumbnail_id( $attachment_id );
$preview = '';
if ( $poster_id ) {
$preview = wp_get_attachment_image(
$poster_id,
'thumbnail',
false,
array(
'class' => 'woocommerce-product-gallery__video-preview',
)
);
}
if ( $preview ) {
return $preview;
}
$video_src = wp_get_attachment_url( $attachment_id );
if ( $video_src ) {
return sprintf(
'<video class="woocommerce-product-gallery__video-preview" src="%1$s" preload="metadata" muted="muted" aria-hidden="true"></video>',
esc_url( $video_src )
);
}
return wp_get_attachment_image(
$attachment_id,
'thumbnail',
true,
array(
'class' => 'woocommerce-product-gallery__video-preview',
)
);
}