/** * Builds the Video shortcode output. * * This implements the functionality of the Video Shortcode for displaying * WordPress mp4s in a post. * * @since 3.6.0 * * @global int $content_width * @staticvar int $instance * * @param array $attr { * Attributes of the shortcode. * * @type string $src URL to the source of the video file. Default empty. * @type int $height Height of the video embed in pixels. Default 360. * @type int $width Width of the video embed in pixels. Default $content_width or 640. * @type string $poster The 'poster' attribute for the `<video>` element. Default empty. * @type string $loop The 'loop' attribute for the `<video>` element. Default empty. * @type string $autoplay The 'autoplay' attribute for the `<video>` element. Default empty. * @type string $preload The 'preload' attribute for the `<video>` element. * Default 'metadata'. * @type string $class The 'class' attribute for the `<video>` element. * Default 'wp-video-shortcode'. * } * @param string $content Shortcode content. * @return string|void HTML content to display video. */ function wp_video_shortcode($attr, $content = '') { global $content_width; $post_id = get_post() ? get_the_ID() : 0; static $instance = 0; $instance++; /** * Filter the default video shortcode output. * * If the filtered output isn't empty, it will be used instead of generating * the default video template. * * @since 3.6.0 * * @see wp_video_shortcode() * * @param string $html Empty variable to be replaced with shortcode markup. * @param array $attr Attributes of the video shortcode. * @param string $content Video shortcode content. * @param int $instance Unique numeric ID of this video shortcode instance. */ $override = apply_filters('wp_video_shortcode_override', '', $attr, $content, $instance); if ('' !== $override) { return $override; } $video = null; $default_types = wp_get_video_extensions(); $defaults_atts = array('src' => '', 'poster' => '', 'loop' => '', 'autoplay' => '', 'preload' => 'metadata', 'width' => 640, 'height' => 360); foreach ($default_types as $type) { $defaults_atts[$type] = ''; } $atts = shortcode_atts($defaults_atts, $attr, 'video'); if (is_admin()) { // shrink the video so it isn't huge in the admin if ($atts['width'] > $defaults_atts['width']) { $atts['height'] = round($atts['height'] * $defaults_atts['width'] / $atts['width']); $atts['width'] = $defaults_atts['width']; } } else { // if the video is bigger than the theme if (!empty($content_width) && $atts['width'] > $content_width) { $atts['height'] = round($atts['height'] * $content_width / $atts['width']); $atts['width'] = $content_width; } } $is_vimeo = $is_youtube = false; $yt_pattern = '#^https?://(?:www\\.)?(?:youtube\\.com/watch|youtu\\.be/)#'; $vimeo_pattern = '#^https?://(.+\\.)?vimeo\\.com/.*#'; $primary = false; if (!empty($atts['src'])) { $is_vimeo = preg_match($vimeo_pattern, $atts['src']); $is_youtube = preg_match($yt_pattern, $atts['src']); if (!$is_youtube && !$is_vimeo) { $type = wp_check_filetype($atts['src'], wp_get_mime_types()); if (!in_array(strtolower($type['ext']), $default_types)) { return sprintf('<a class="wp-embedded-video" href="%s">%s</a>', esc_url($atts['src']), esc_html($atts['src'])); } } if ($is_vimeo) { wp_enqueue_script('froogaloop'); } $primary = true; array_unshift($default_types, 'src'); } else { foreach ($default_types as $ext) { if (!empty($atts[$ext])) { $type = wp_check_filetype($atts[$ext], wp_get_mime_types()); if (strtolower($type['ext']) === $ext) { $primary = true; } } } } if (!$primary) { $videos = get_attached_media('video', $post_id); if (empty($videos)) { return; } $video = reset($videos); $atts['src'] = wp_get_attachment_url($video->ID); if (empty($atts['src'])) { return; } array_unshift($default_types, 'src'); } /** * Filter the media library used for the video shortcode. * * @since 3.6.0 * * @param string $library Media library used for the video shortcode. */ $library = apply_filters('wp_video_shortcode_library', 'mediaelement'); if ('mediaelement' === $library && did_action('init')) { wp_enqueue_style('wp-mediaelement'); wp_enqueue_script('wp-mediaelement'); } /** * Filter the class attribute for the video shortcode output container. * * @since 3.6.0 * * @param string $class CSS class or list of space-separated classes. */ $html_atts = array('class' => apply_filters('wp_video_shortcode_class', 'wp-video-shortcode'), 'id' => sprintf('video-%d-%d', $post_id, $instance), 'width' => absint($atts['width']), 'height' => absint($atts['height']), 'poster' => esc_url($atts['poster']), 'loop' => wp_validate_boolean($atts['loop']), 'autoplay' => wp_validate_boolean($atts['autoplay']), 'preload' => $atts['preload']); // These ones should just be omitted altogether if they are blank foreach (array('poster', 'loop', 'autoplay', 'preload') as $a) { if (empty($html_atts[$a])) { unset($html_atts[$a]); } } $attr_strings = array(); foreach ($html_atts as $k => $v) { $attr_strings[] = $k . '="' . esc_attr($v) . '"'; } $html = ''; if ('mediaelement' === $library && 1 === $instance) { $html .= "<!--[if lt IE 9]><script>document.createElement('video');</script><![endif]-->\n"; } $html .= sprintf('<video %s controls="controls">', join(' ', $attr_strings)); $fileurl = ''; $source = '<source type="%s" src="%s" />'; foreach ($default_types as $fallback) { if (!empty($atts[$fallback])) { if (empty($fileurl)) { $fileurl = $atts[$fallback]; } if ('src' === $fallback && $is_youtube) { $type = array('type' => 'video/youtube'); } elseif ('src' === $fallback && $is_vimeo) { $type = array('type' => 'video/vimeo'); } else { $type = wp_check_filetype($atts[$fallback], wp_get_mime_types()); } $url = add_query_arg('_', $instance, $atts[$fallback]); $html .= sprintf($source, $type['type'], esc_url($url)); } } if (!empty($content)) { if (false !== strpos($content, "\n")) { $content = str_replace(array("\r\n", "\n", "\t"), '', $content); } $html .= trim($content); } if ('mediaelement' === $library) { $html .= wp_mediaelement_fallback($fileurl); } $html .= '</video>'; $width_rule = ''; if (!empty($atts['width'])) { $width_rule = sprintf('width: %dpx; ', $atts['width']); } $output = sprintf('<div style="%s" class="wp-video">%s</div>', $width_rule, $html); /** * Filter the output of the video shortcode. * * @since 3.6.0 * * @param string $output Video shortcode HTML output. * @param array $atts Array of video shortcode attributes. * @param string $video Video file. * @param int $post_id Post ID. * @param string $library Media library used for the video shortcode. */ return apply_filters('wp_video_shortcode', $output, $atts, $video, $post_id, $library); }
function custom_video_shortcode($attr, $content = '') { global $content_width; $post_id = get_post() ? get_the_ID() : 0; static $instances = 0; $instances++; /** * Override the default video shortcode. * * @since 3.7.0 * * @param null Empty variable to be replaced with shortcode markup. * @param array $attr Attributes of the shortcode. * @param string $content Shortcode content. * @param int $instances Unique numeric ID of this video shortcode instance. */ $html = apply_filters('wp_video_shortcode_override', '', $attr, $content, $instances); if ('' !== $html) { return $html; } $video = null; $default_types = wp_get_video_extensions(); $defaults_atts = array('src' => '', 'poster' => '', 'loop' => '', 'autoplay' => '', 'preload' => 'metadata', 'height' => 1080, 'width' => empty($content_width) ? 1920 : $content_width, 'size' => ''); foreach ($default_types as $type) { $defaults_atts[$type] = ''; } $atts = shortcode_atts($defaults_atts, $attr, 'video'); extract($atts); $w = $width; $h = $height; if (is_admin() && $width > 600) { $w = 1920; } elseif (!is_admin() && $w > $defaults_atts['width']) { $w = $defaults_atts['width']; } if ($w < $width) { $height = round($h * $w / $width); } $width = $w; $primary = false; if (!empty($src)) { $type = wp_check_filetype($src, wp_get_mime_types()); if (!in_array(strtolower($type['ext']), $default_types)) { return sprintf('<a class="wp-embedded-video" href="%s">%s</a>', esc_url($src), esc_html($src)); } $primary = true; array_unshift($default_types, 'src'); } else { foreach ($default_types as $ext) { if (!empty(${$ext})) { $type = wp_check_filetype(${$ext}, wp_get_mime_types()); if (strtolower($type['ext']) === $ext) { $primary = true; } } } } if (!$primary) { $videos = get_attached_media('video', $post_id); if (empty($videos)) { return; } $video = reset($videos); $src = wp_get_attachment_url($video->ID); if (empty($src)) { return; } array_unshift($default_types, 'src'); } $library = apply_filters('wp_video_shortcode_library', 'mediaelement'); /*if ( 'mediaelement' === $library && did_action( 'init' ) ) { wp_enqueue_style( 'wp-mediaelement' ); wp_enqueue_script( 'wp-mediaelement' ); } /*$atts = array( 'class' => apply_filters( 'wp_video_shortcode_class', 'wp-video-shortcode' ), 'id' => sprintf( 'video-%d-%d', $post_id, $instances ), 'width' => absint( $width ), 'height' => absint( $height ), 'poster' => esc_url( $poster ), 'loop' => $loop, 'autoplay' => $autoplay, 'preload' => $preload, );*/ // These ones should just be omitted altogether if they are blank foreach (array('poster', 'loop', 'autoplay', 'preload') as $a) { if (empty($atts[$a])) { unset($atts[$a]); } } $attr_strings = array(); foreach ($atts as $k => $v) { $attr_strings[] = $k . '="' . esc_attr($v) . '"'; } $html .= '<video id="videoplayer" class="video-js vjs-mnml ' . $size . '" controls="controls" data-setup>'; $fileurl = ''; $source = '<source type="%s" src="%s" />'; foreach ($default_types as $fallback) { if (!empty(${$fallback})) { if (empty($fileurl)) { $fileurl = ${$fallback}; } $type = wp_check_filetype(${$fallback}, wp_get_mime_types()); // m4v sometimes shows up as video/mpeg which collides with mp4 if ('m4v' === $type['ext']) { $type['type'] = 'video/m4v'; } $html .= sprintf($source, $type['type'], esc_url(${$fallback})); } } if ('mediaelement' === $library) { $html .= wp_mediaelement_fallback($fileurl); } $html .= '</video>'; $html = sprintf('<div class="wp-video">%s</div>', $html); return apply_filters('wp_video_shortcode', $html, $atts, $video, $post_id, $library); }
/** * The Video shortcode. * * This implements the functionality of the Video Shortcode for displaying * WordPress mp4s in a post. * * @since 3.6.0 * * @param array $attr Attributes of the shortcode. * @return string HTML content to display video. */ function wp_video_shortcode($attr) { global $content_width; $post_id = get_post() ? get_the_ID() : 0; static $instances = 0; $instances++; $video = null; $default_types = wp_get_video_extensions(); $defaults_atts = array('src' => '', 'poster' => '', 'loop' => '', 'autoplay' => '', 'preload' => 'metadata', 'height' => 360, 'width' => empty($content_width) ? 640 : $content_width); foreach ($default_types as $type) { $defaults_atts[$type] = ''; } $atts = shortcode_atts($defaults_atts, $attr, 'video'); extract($atts); $w = $width; $h = $height; if (is_admin() && $width > 600) { $w = 600; } elseif (!is_admin() && $w > $defaults_atts['width']) { $w = $defaults_atts['width']; } if ($w < $width) { $height = round($h * $w / $width); } $width = $w; $primary = false; if (!empty($src)) { $type = wp_check_filetype($src, wp_get_mime_types()); if (!in_array($type['ext'], $default_types)) { return sprintf('<a class="wp-embedded-video" href="%s">%s</a>', esc_url($src), esc_html($src)); } $primary = true; array_unshift($default_types, 'src'); } else { foreach ($default_types as $ext) { if (!empty(${$ext})) { $type = wp_check_filetype(${$ext}, wp_get_mime_types()); if ($type['ext'] === $ext) { $primary = true; } } } } if (!$primary) { $videos = get_attached_media('video', $post_id); if (empty($videos)) { return; } $video = reset($videos); $src = wp_get_attachment_url($video->ID); if (empty($src)) { return; } array_unshift($default_types, 'src'); } $library = apply_filters('wp_video_shortcode_library', 'mediaelement'); if ('mediaelement' === $library && did_action('init')) { wp_enqueue_style('wp-mediaelement'); wp_enqueue_script('wp-mediaelement'); } $atts = array('class' => apply_filters('wp_video_shortcode_class', 'wp-video-shortcode'), 'id' => sprintf('video-%d-%d', $post_id, $instances), 'width' => absint($width), 'height' => absint($height), 'poster' => esc_url($poster), 'loop' => $loop, 'autoplay' => $autoplay, 'preload' => $preload); // These ones should just be omitted altogether if they are blank foreach (array('poster', 'loop', 'autoplay', 'preload') as $a) { if (empty($atts[$a])) { unset($atts[$a]); } } $attr_strings = array(); foreach ($atts as $k => $v) { $attr_strings[] = $k . '="' . esc_attr($v) . '"'; } $html = ''; if ('mediaelement' === $library && 1 === $instances) { $html .= "<!--[if lt IE 9]><script>document.createElement('video');</script><![endif]-->\n"; } $html .= sprintf('<video %s controls="controls">', join(' ', $attr_strings)); $fileurl = ''; $source = '<source type="%s" src="%s" />'; foreach ($default_types as $fallback) { if (!empty(${$fallback})) { if (empty($fileurl)) { $fileurl = ${$fallback}; } $type = wp_check_filetype(${$fallback}, wp_get_mime_types()); // m4v sometimes shows up as video/mpeg which collides with mp4 if ('m4v' === $type['ext']) { $type['type'] = 'video/m4v'; } $html .= sprintf($source, $type['type'], esc_url(${$fallback})); } } if ('mediaelement' === $library) { $html .= wp_mediaelement_fallback($fileurl); } $html .= '</video>'; $html = sprintf('<div style="width: %dpx; max-width: 100%%;">%s</div>', $width, $html); return apply_filters('wp_video_shortcode', $html, $atts, $video, $post_id, $library); }
/** * The Video shortcode. * * This implements the functionality of the Video Shortcode for displaying * WordPress mp4s in a post. * * @since 3.6.0 * * @param array $attr Attributes of the shortcode. * @return string HTML content to display video. */ function wp_video_shortcode($attr) { global $content_width; $post_id = get_post() ? get_the_ID() : 0; static $instances = 0; $instances++; $video = null; $default_types = wp_get_video_extensions(); $defaults_atts = array('src' => '', 'poster' => '', 'height' => 360, 'width' => empty($content_width) ? 640 : $content_width); foreach ($default_types as $type) { $defaults_atts[$type] = ''; } $atts = shortcode_atts($defaults_atts, $attr, 'video'); extract($atts); $w = $width; $h = $height; if (is_admin() && $width > 600) { $w = 600; } elseif (!is_admin() && $w > $defaults_atts['width']) { $w = $defaults_atts['width']; } if ($w < $width) { $height = round($h * $w / $width); } $width = $w; $primary = false; if (!empty($src)) { $type = wp_check_filetype($src); if (!in_array($type['ext'], $default_types)) { return sprintf('<a class="wp-post-format-link-video" href="%1$s">%1$s</a>', $src); } $primary = true; array_unshift($default_types, 'src'); } else { foreach ($default_types as $ext) { if (!empty(${$ext})) { $type = wp_check_filetype(${$ext}); if ($type['ext'] === $ext) { $primary = true; } } } } if (!$primary) { $videos = get_attached_video($post_id); if (empty($videos)) { return; } $video = reset($videos); $src = wp_get_attachment_url($video->ID); if (empty($src)) { return; } array_unshift($default_types, 'src'); } $library = apply_filters('wp_video_shortcode_library', 'mediaelement'); if ('mediaelement' === $library && did_action('init')) { wp_enqueue_style('wp-mediaelement'); wp_enqueue_script('wp-mediaelement'); } $atts = array(sprintf('class="%s"', apply_filters('wp_video_shortcode_class', 'wp-video-shortcode')), sprintf('id="video-%d-%d"', $post_id, $instances), sprintf('width="%d"', $width), sprintf('height="%d"', $height)); if (!empty($poster)) { $atts[] = sprintf('poster="%s"', esc_url($poster)); } $html = sprintf('<video %s controls="controls" preload="none">', join(' ', $atts)); $fileurl = ''; $source = '<source type="%s" src="%s" />'; foreach ($default_types as $fallback) { if (!empty(${$fallback})) { if (empty($fileurl)) { $fileurl = ${$fallback}; } $type = wp_check_filetype(${$fallback}); // m4v sometimes shows up as video/mpeg which collides with mp4 if ('m4v' === $type['ext']) { $type['type'] = 'video/m4v'; } $html .= sprintf($source, $type['type'], ${$fallback}); } } if ('mediaelement' === $library) { $html .= wp_mediaelement_fallback($fileurl); } $html .= '</video>'; return apply_filters('wp_video_shortcode', $html, $atts, $video, $post_id); }
/** * The Video shortcode. * Pretty much a copy-paste of the wp_video_shortcode function from wp-includes/media.php */ function video_shortcode($html, $attr, $content, $instances) { global $content_width; $post_id = get_post() ? get_the_ID() : 0; // do not modify video display on the admin side if (is_admin()) { return ''; } static $instances = 0; $instances++; $video = null; $default_types = wp_get_video_extensions(); $defaults_atts = array('src' => '', 'poster' => '', 'loop' => '', 'autoplay' => '', 'preload' => 'metadata', 'width' => 640, 'height' => 360); foreach ($default_types as $type) { $defaults_atts[$type] = ''; } $atts = shortcode_atts($defaults_atts, $attr, 'video'); if (is_admin()) { // shrink the video so it isn't huge in the admin if ($atts['width'] > $defaults_atts['width']) { $atts['height'] = round($atts['height'] * $defaults_atts['width'] / $atts['width']); $atts['width'] = $defaults_atts['width']; } } else { // if the video is bigger than the theme if (!empty($content_width) && $atts['width'] > $content_width) { $atts['height'] = round($atts['height'] * $content_width / $atts['width']); $atts['width'] = $content_width; } } $yt_pattern = '#^https?://(?:www\\.)?(?:youtube\\.com/watch|youtu\\.be/)#'; // Skrollr : add Dailymotion pattern $dm_pattern = '#^https?://(?:www\\.)?(?:dailymotion\\.com/video/|dai\\.ly/)#'; // End Skrollr $primary = false; if (!empty($atts['src'])) { if (!preg_match($yt_pattern, $atts['src']) && !preg_match($dm_pattern, $atts['src'])) { // Skrollr : add Dailymotion pattern $type = wp_check_filetype($atts['src'], wp_get_mime_types()); if (!in_array(strtolower($type['ext']), $default_types)) { return sprintf('<a class="wp-embedded-video" href="%s">%s</a>', esc_url($atts['src']), esc_html($atts['src'])); } } $primary = true; array_unshift($default_types, 'src'); } else { foreach ($default_types as $ext) { if (!empty($atts[$ext])) { $type = wp_check_filetype($atts[$ext], wp_get_mime_types()); if (strtolower($type['ext']) === $ext) { $primary = true; } } } } if (!$primary) { $videos = get_attached_media('video', $post_id); if (empty($videos)) { return; } $video = reset($videos); $atts['src'] = wp_get_attachment_url($video->ID); if (empty($atts['src'])) { return; } array_unshift($default_types, 'src'); } /** * Filter the class attribute for the video shortcode output container. * * @since 3.6.0 * * @param string $class CSS class or list of space-separated classes. */ $html_atts = array('class' => apply_filters('wp_video_shortcode_class', 'wp-video-shortcode'), 'id' => sprintf('video-%d-%d', $post_id, $instances), 'width' => '100%', 'height' => '100%', 'poster' => esc_url($atts['poster']), 'loop' => $atts['loop'], 'autoplay' => $atts['autoplay'], 'preload' => $atts['preload']); // These ones should just be omitted altogether if they are blank foreach (array('poster', 'loop', 'autoplay', 'preload') as $a) { if (empty($html_atts[$a])) { unset($html_atts[$a]); } } $attr_strings = array(); foreach ($html_atts as $k => $v) { $attr_strings[] = $k . '="' . esc_attr($v) . '"'; } $html = ''; $html .= sprintf('<video %s controls="controls">', join(' ', $attr_strings)); $fileurl = ''; $source = '<source type="%s" src="%s" />'; foreach ($default_types as $fallback) { if (!empty($atts[$fallback])) { if (empty($fileurl)) { $fileurl = $atts[$fallback]; } if ('src' === $fallback && preg_match($yt_pattern, $atts['src'])) { $type = array('type' => 'video/youtube'); } else { if ('src' === $fallback && preg_match($dm_pattern, $atts['src'])) { // Skrollr : add Dailymotion pattern $type = array('type' => 'video/dailymotion'); } else { $type = wp_check_filetype($atts[$fallback], wp_get_mime_types()); } } // Skrollr : remove '_' in URL query args $url = $atts[$fallback]; $html .= sprintf($source, $type['type'], esc_url($url)); } } if (!empty($content)) { if (false !== strpos($content, "\n")) { $content = str_replace(array("\r\n", "\n", "\t"), '', $content); } $html .= trim($content); } $html .= wp_mediaelement_fallback($fileurl); $html .= '</video>'; // use the post content as a legend global $post; $content = strip_shortcodes(get_the_content()); if (trim($content) != '') { $html .= "<figcaption "; $html .= "data--0p-bottom-top=\"opacity:1\" "; $html .= "data--100p-bottom-top=\"opacity:1\" "; $html .= "data--120p-bottom-top=\"opacity:0\""; $html .= "data-anchor-target=\"#{$post->post_name}\" "; $html .= ">{$content}</figcaption>"; } // Skrollr : remove width and height rules return sprintf('<div class="wp-video">%s</div>', $html); }
public static function video($attr) { $post_id = get_post() ? get_the_ID() : 0; static $instances = 0; $instances++; $video = null; $default_types = wp_get_video_extensions(); $defaults_atts = array('src' => '', 'poster' => '', 'loop' => '', 'autoplay' => '', 'preload' => 'metadata', 'width' => 640, 'height' => 360); foreach ($default_types as $type) { $defaults_atts[$type] = ''; } $atts = shortcode_atts($defaults_atts, $attr, 'video'); $yt_pattern = '#^https?://(?:www\\.)?(?:youtube\\.com/watch|youtu\\.be/)#'; $primary = false; if (!empty($atts['src'])) { if (!preg_match($yt_pattern, $atts['src'])) { $type = wp_check_filetype($atts['src'], wp_get_mime_types()); if (!in_array(strtolower($type['ext']), $default_types)) { return sprintf('<a class="wp-embedded-video" href="%s">%s</a>', esc_url($atts['src']), esc_html($atts['src'])); } } $primary = true; array_unshift($default_types, 'src'); } else { foreach ($default_types as $ext) { if (!empty($atts[$ext])) { $type = wp_check_filetype($atts[$ext], wp_get_mime_types()); if (strtolower($type['ext']) === $ext) { $primary = true; } } } } if (!$primary) { $videos = get_attached_media('video', $post_id); if (empty($videos)) { return; } $video = reset($videos); $atts['src'] = wp_get_attachment_url($video->ID); if (empty($atts['src'])) { return; } array_unshift($default_types, 'src'); } $library = apply_filters('wp_video_shortcode_library', 'mediaelement'); if ('mediaelement' === $library && did_action('init')) { wp_enqueue_style('wp-mediaelement'); wp_enqueue_script('wp-mediaelement'); } $html_atts = array('class' => apply_filters('wp_video_shortcode_class', 'wp-video-shortcode'), 'id' => sprintf('video-%d-%d', $post_id, $instances), 'width' => absint($atts['width']), 'height' => absint($atts['height']), 'poster' => esc_url($atts['poster']), 'loop' => $atts['loop'], 'autoplay' => $atts['autoplay'], 'preload' => $atts['preload']); foreach (array('poster', 'loop', 'autoplay', 'preload') as $a) { if (empty($html_atts[$a])) { unset($html_atts[$a]); } } $attr_strings = array(); foreach ($html_atts as $k => $v) { $attr_strings[] = $k . '="' . esc_attr($v) . '"'; } $html = ''; if ('mediaelement' === $library && 1 === $instances) { $html .= "<!--[if lt IE 9]><script>document.createElement('video');</script><![endif]-->\n"; } $html .= sprintf('<video %s controls="controls">', join(' ', $attr_strings)); $fileurl = ''; $source = '<source type="%s" src="%s" />'; foreach ($default_types as $fallback) { if (!empty($atts[$fallback])) { if (empty($fileurl)) { $fileurl = $atts[$fallback]; } if ('src' === $fallback && preg_match($yt_pattern, $atts['src'])) { $type = array('type' => 'video/youtube'); } else { $type = wp_check_filetype($atts[$fallback], wp_get_mime_types()); } $url = add_query_arg('_', $instances, $atts[$fallback]); $html .= sprintf($source, $type['type'], esc_url($url)); } } if ('mediaelement' === $library) { $html .= wp_mediaelement_fallback($fileurl); } $html .= '</video>'; $width_rule = $height_rule = ''; if (!empty($atts['width'])) { $width_rule = sprintf('width: %dpx; ', $atts['width']); } if (!empty($atts['height'])) { $height_rule = sprintf('height: %dpx;', $atts['height']); } $output = sprintf('<div style="%s%s" class="wp-video">%s</div>', $width_rule, $height_rule, $html); return $output; }