. '" height="' . $allowed_resolutions[ $args['resolution'] ]['height'] . '">';
if ( isset( $args['lazy_image'] ) && $args['lazy_image'] ) {
$attributes = 'alt="" width="' . $allowed_resolutions[ $args['resolution'] ]['width'] . '" height="' . $allowed_resolutions[ $args['resolution'] ]['height'] . '"';
$image = '';
if ( $args['native'] ) {
$image = '';
}
}
return "";
}
/**
* Inserts the CSS to style the Youtube thumbnail container
*
* @param array $args Array of arguments to populate the CSS.
* @return void
*/
public function insertYoutubeThumbnailCSS( $args = [] ) {
wp_register_style( 'rocket-lazyload', false ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
wp_enqueue_style( 'rocket-lazyload' );
wp_add_inline_style( 'rocket-lazyload', $this->getYoutubeThumbnailCSS( $args ) );
}
/**
* Returns the CSS for the Youtube Thumbnail
*
* @param array $args Array of arguments to populate the CSS.
* @return string
*/
public function getYoutubeThumbnailCSS( $args = [] ) {
$defaults = [
'base_url' => '',
'responsive_embeds' => true,
];
$args = wp_parse_args( $args, $defaults );
$css = '.rll-youtube-player{position:relative;padding-bottom:56.23%;height:0;overflow:hidden;max-width:100%;}.rll-youtube-player:focus-within{outline: 2px solid currentColor;outline-offset: 5px;}.rll-youtube-player iframe{position:absolute;top:0;left:0;width:100%;height:100%;z-index:100;background:0 0}.rll-youtube-player img{bottom:0;display:block;left:0;margin:auto;max-width:100%;width:100%;position:absolute;right:0;top:0;border:none;height:auto;-webkit-transition:.4s all;-moz-transition:.4s all;transition:.4s all}.rll-youtube-player img:hover{-webkit-filter:brightness(75%)}.rll-youtube-player .play{height:100%;width:100%;left:0;top:0;position:absolute;background:url(' . $args['base_url'] . 'img/youtube.png) no-repeat center;background-color: transparent !important;cursor:pointer;border:none;}';
if ( $args['responsive_embeds'] ) {
$css .= '.wp-embed-responsive .wp-has-aspect-ratio .rll-youtube-player{position:absolute;padding-bottom:0;width:100%;height:100%;top:0;bottom:0;left:0;right:0}';
}
return $css;
}
/**
* Inserts the CSS needed when Javascript is not enabled to keep the display correct
*/
public function insertNoJSCSS() {
echo $this->getNoJSCSS(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/**
* Returns the CSS to correctly display images when JavaScript is disabled
*
* @return string
*/
public function getNoJSCSS() {
return '';
}
}