function swell_video_thumbnail($id) { $content_post = get_post($id); $content = $content_post->post_content; $video = swell_embed_parser($content); if ($video['type'] == "youtube") { // ToDo: Get poster frame via the API to avoid broken links if YT changes this format $swell_video_thumbnail = '<img class="youtube-thumb" src="http://img.youtube.com/vi/' . $video['id'] . '/0.jpg" />'; } elseif ($video['type'] == "vimeo") { $imgid = $video['id']; $hash = unserialize(file_get_contents("http://vimeo.com/api/v2/video/{$imgid}.php")); $thumbURL = $hash[0]['thumbnail_large']; $swell_video_thumbnail = '<img class="vimeo-thumb" src="' . $thumbURL . '" />'; } else { $swell_video_thumbnail = '<img src="' . get_bloginfo('template_url') . '/images/no_video.jpg" width="500" />'; } echo $swell_video_thumbnail; }
<?php $link = get_theme_mod('swell_home_video'); $video = swell_embed_parser($link); ?> <div id="video-background" class="video-background<?php if (!$link) { echo ' no-video'; } ?> " <?php if (get_theme_mod('swell_home_image')) { ?> style="background-image: url('<?php echo get_theme_mod('swell_home_image'); ?> ');" <?php } ?> > <div id="banner-content"> <div class="inside"> <div class="content"><?php echo wpautop(wp_kses_post(do_shortcode(get_theme_mod('swell_home_banner_text_main')))); ?> </div> </div> </div> <?php
function swell_video_embed($link) { global $ttrust_config; $video = swell_embed_parser($link); switch ($video['type']) { case 'youtube': ?> <div id="youtube<?php echo $ttrust_config['video_counter']; ?> " class="video-container player" style="display:block; margin: auto; background: rgba(0,0,0,0.5)" data-property="{ videoURL:'<?php echo $video['url']; ?> ', containment:'#youtube<?php echo $ttrust_config['video_counter']++; ?> ', mute:true, autoPlay:true, loop:true, opacity:1 }"></div><?php break; case 'vimeo': ?> <div class="video-container"> <iframe class="vimeo player" id="vimeo<?php echo $ttrust_config['video_counter']; ?> " src="<?php echo $video['url']; ?> ?api=1&loop=1&portrait=0&controls=0&showinfo=0&autohide=1&rel=0&wmode=transparent&output=embed&player_id=vimeo<?php echo $ttrust_config['video_counter']++; ?> " width="100%" height="100%"></iframe> </div><?php break; case 'self': ?> <div class="video-container" style="width: 100%; height: 100%;" > <video id="self<?php echo $ttrust_config['video_counter']; ?> " class="html5-video player" width="100%" height="100%" <?php if (get_theme_mod('swell_home_image')) { ?> poster="<?php echo get_theme_mod('swell_home_image'); ?> " <?php } ?> loop autoplay muted oncanplay="playSelfVideo(self<?php echo $ttrust_config['video_counter']++; ?> )"> <!-- mp4 --> <source src="<?php echo $video['url']; ?> .mp4" type='video/mp4' /> <!-- webm --> <source src="<?php echo $video['url']; ?> .webm" type='video/webm' /> <!-- ogg --> <source src="<?php echo $video['url']; ?> .ogv" type='video/ogv' /> <?php _e('Sorry, but it seems like your browser doesnt support HTML5 video.', 'swell'); ?> </video> </div><?php break; default: break; } // switch() }