Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function materialis_print_header_video()
- {
- add_filter('oembed_fetch_url', 'materialis_oembed_autoplay_loop_args', 10, 3);
- add_filter('oembed_result', 'materialis_add_autoplay_loop_to_oembed', 10, 3);
- $video = materialis_get_theme_mod('playsinline', 'header_content_video', 'https://www.youtube.com/watch?v=3iXYciBTQ0c');
- $embed = new WP_Embed();
- $autoplay = materialis_get_theme_mod('header_content_video_autoplay', '1');
- $mute = materialis_get_theme_mod('header_content_video_mute', '0');
- if (materialis_is_customize_preview()) {
- $autoplay = false;
- }
- $content = $embed->shortcode(array(
- 'src' => $video,
- 'autoplay' => $autoplay,
- 'playsinline' => $autoplay,
- 'mute' => $mute,
- 'loop' => materialis_get_theme_mod('header_content_video_loop', '0'),
- ));
- $content = preg_replace('/width="\d+"/', "", $content);
- $content = preg_replace('/height="\d+"/', 'class="header-hero-video"', $content);
- $class = "";
- if (strpos($content, '<iframe') !== false) {
- $class = "iframe-holder ";
- }
- remove_filter('oembed_fetch_url', 'materialis_oembed_autoplay_loop_args');
- remove_filter('oembed_result', 'materialis_add_autoplay_loop_to_oembed');
- echo '<div class="content-video-container ' . $class . '">' . $content . '</div>';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement