Automattic\WooCommerce\Internal\ProductGallery

ProductMediaGallery::get_video_poster_id │ public static │ WC 1.0

Get the poster attachment ID for a gallery video item.

Method of the class: ProductMediaGallery{}

No Hooks.

Returns

int.

Usage

$result = ProductMediaGallery::get_video_poster_id( $media_item ): int;
$media_item(array) (required)
Product media gallery item.

ProductMediaGallery::get_video_poster_id() code WC 11.1.2

public static function get_video_poster_id( array $media_item ): int {
	$poster_id = isset( $media_item['poster_id'] ) ? absint( $media_item['poster_id'] ) : 0;

	if ( $poster_id ) {
		return $poster_id;
	}

	$attachment_id = isset( $media_item['id'] ) ? absint( $media_item['id'] ) : 0;

	return $attachment_id ? (int) get_post_thumbnail_id( $attachment_id ) : 0;
}