| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Player |
| 5 |
* |
| 6 |
* @link https://plugins360.com |
| 7 |
* @since 2.5.0 |
| 8 |
* |
| 9 |
* @package Automatic_YouTube_Gallery |
| 10 |
*/ |
| 11 |
|
| 12 |
$player_ratio = ! empty( $attributes['player_ratio'] ) ? (float) $attributes['player_ratio'] : '56.25'; |
| 13 |
|
| 14 |
$video_attributes = array( |
| 15 |
'src' => esc_url( ayg_get_youtube_embed_url( $video->id, $attributes ) ), |
| 16 |
'ratio' => $player_ratio |
| 17 |
); |
| 18 |
|
| 19 |
if ( isset( $video->title ) ) { |
| 20 |
$video_attributes['title'] = esc_attr( $video->title ); |
| 21 |
} |
| 22 |
|
| 23 |
if ( isset( $attributes['poster'] ) && ! empty( $attributes['poster'] ) ) { |
| 24 |
$video_attributes['poster'] = $attributes['poster']; |
| 25 |
} else { |
| 26 |
if ( isset( $video->thumbnails->default ) ) { |
| 27 |
$video_attributes['poster'] = $video->thumbnails->default->url; |
| 28 |
} |
| 29 |
|
| 30 |
if ( 75 == $player_ratio ) { // 4:3 ( default - 120x90, high - 480x360, standard - 640x480 ) |
| 31 |
if ( isset( $video->thumbnails->high ) ) { |
| 32 |
$video_attributes['poster'] = $video->thumbnails->high->url; |
| 33 |
} |
| 34 |
|
| 35 |
if ( isset( $video->thumbnails->standard ) ) { |
| 36 |
$video_attributes['poster'] = $video->thumbnails->standard->url; |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
if ( 56.25 == $player_ratio ) { // 16:9 ( medium - 320x180, maxres - 1280x720 ) |
| 41 |
if ( isset( $video->thumbnails->medium ) ) { |
| 42 |
$video_attributes['poster'] = $video->thumbnails->medium->url; |
| 43 |
} |
| 44 |
|
| 45 |
if ( isset( $video->thumbnails->maxres ) ) { |
| 46 |
$video_attributes['poster'] = $video->thumbnails->maxres->url; |
| 47 |
} |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
if ( isset( $video_attributes['poster'] ) ) { |
| 52 |
$video_attributes['poster'] = esc_url( $video_attributes['poster'] ); |
| 53 |
} |
| 54 |
|
| 55 |
if ( ! empty( $attributes['lazyload'] ) ) { |
| 56 |
$video_attributes['lazyload'] = ''; |
| 57 |
} |
| 58 |
|
| 59 |
$player_html = sprintf( '<ayg-player %s></ayg-player>', ayg_combine_video_attributes( $video_attributes ) ); |
| 60 |
|
| 61 |
// Allow filtering before output |
| 62 |
echo apply_filters( 'the_ayg_player', $player_html, $video, $attributes ); |