| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Thumbnail |
| 5 |
* |
| 6 |
* @link https://plugins360.com |
| 7 |
* @since 1.0.0 |
| 8 |
* |
| 9 |
* @package Automatic_YouTube_Gallery |
| 10 |
*/ |
| 11 |
|
| 12 |
$single_url = ayg_get_single_video_url( $video, $attributes ); |
| 13 |
?> |
| 14 |
<div class="ayg-thumbnail" data-id="<?php echo esc_attr( $video->id ); ?>" data-title="<?php echo esc_attr( $video->title ); ?>" data-url="<?php echo esc_attr( $single_url ); ?>"> |
| 15 |
<div class="ayg-thumbnail-media"> |
| 16 |
<?php |
| 17 |
// Image |
| 18 |
$image_url = ''; |
| 19 |
|
| 20 |
if ( isset( $video->thumbnails->default ) ) { |
| 21 |
$image_url = $video->thumbnails->default->url; |
| 22 |
} |
| 23 |
|
| 24 |
if ( 75 == (int) $attributes['thumb_ratio'] ) { // 4:3 ( default - 120x90, high - 480x360, standard - 640x480 ) |
| 25 |
if ( isset( $video->thumbnails->high ) ) { |
| 26 |
$image_url = $video->thumbnails->high->url; |
| 27 |
} |
| 28 |
|
| 29 |
if ( isset( $video->thumbnails->standard ) ) { |
| 30 |
$image_url = $video->thumbnails->standard->url; |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
if ( 56.25 == (float) $attributes['thumb_ratio'] ) { // 16:9 ( medium - 320x180, maxres - 1280x720 ) |
| 35 |
if ( isset( $video->thumbnails->medium ) ) { |
| 36 |
$image_url = $video->thumbnails->medium->url; |
| 37 |
} |
| 38 |
|
| 39 |
if ( isset( $video->thumbnails->maxres ) ) { |
| 40 |
$image_url = $video->thumbnails->maxres->url; |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
$image_url = apply_filters( 'ayg_thumbnail_image_url', $image_url, $video, $attributes ); |
| 45 |
|
| 46 |
echo sprintf( |
| 47 |
'<img src="%s" class="ayg-thumbnail-image" width="320" height="180" alt="%s" %s/>', |
| 48 |
esc_url( $image_url ), |
| 49 |
esc_attr( $video->title ), |
| 50 |
( ! empty( $attributes['lazyload'] ) ? 'loading="lazy"' : '' ) |
| 51 |
); |
| 52 |
|
| 53 |
// Play Icon |
| 54 |
echo sprintf( |
| 55 |
'<svg xmlns="http://www.w3.org/2000/svg" fill="white" width="40" height="40" viewBox="0 0 24 24" class="ayg-icon ayg-thumbnail-icon-play" title="%1$s" aria-label="%1$s"><path fill-rule="evenodd" d="M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12Zm14.024-.983a1.125 1.125 0 0 1 0 1.966l-5.603 3.113A1.125 1.125 0 0 1 9 15.113V8.887c0-.857.921-1.4 1.671-.983l5.603 3.113Z" clip-rule="evenodd" /></svg>', |
| 56 |
esc_attr__( 'Play', 'automatic-youtube-gallery' ) |
| 57 |
); |
| 58 |
|
| 59 |
// Now Playing |
| 60 |
echo sprintf( |
| 61 |
'<div class="ayg-thumbnail-now-playing" style="display: none;">%s</div>', |
| 62 |
esc_html__( 'Now Playing', 'automatic-youtube-gallery' ) |
| 63 |
); |
| 64 |
?> |
| 65 |
</div> |
| 66 |
<div class="ayg-thumbnail-caption"> |
| 67 |
<?php if ( ! empty( $attributes['thumb_title'] ) ) : ?> |
| 68 |
<div class="ayg-thumbnail-title"><?php echo esc_html( ayg_trim_words( $video->title, (int) $attributes['thumb_title_length'] ) ); ?></div> |
| 69 |
<?php endif; ?> |
| 70 |
<?php if ( ! empty( $attributes['thumb_excerpt'] ) && ! empty( $video->description ) ) : ?> |
| 71 |
<div class="ayg-thumbnail-excerpt"><?php echo wp_kses_post( ayg_trim_words( $video->description, (int) $attributes['thumb_excerpt_length'] ) ); ?></div> |
| 72 |
<?php endif; ?> |
| 73 |
<?php if ( ! empty( $attributes['player_description'] ) && ! empty( $video->description ) ) : ?> |
| 74 |
<div class="ayg-thumbnail-description" style="display: none;"><?php echo wp_kses_post( ayg_get_player_description( $video, $attributes ) ); ?></div> |
| 75 |
<?php endif; ?> |
| 76 |
</div> |
| 77 |
</div> |