Example #1
0
function get_video_thumbnail_uri($video_uri)
{
    $thumbnail_uri = '';
    // determine the type of video and the video id
    $video = parse_video_uri($video_uri);
    // get youtube thumbnail
    if ($video['type'] == 'youtube') {
        $thumbnail_uri = 'http://img.youtube.com/vi/' . $video['id'] . '/maxresdefault.jpg';
    }
    // get vimeo thumbnail
    if ($video['type'] == 'vimeo') {
        $thumbnail_uri = get_vimeo_thumbnail_uri($video['id']);
    }
    // get wistia thumbnail
    if ($video['type'] == 'wistia') {
        $thumbnail_uri = get_wistia_thumbnail_uri($video_uri);
    }
    // get default/placeholder thumbnail
    if (empty($thumbnail_uri) || is_wp_error($thumbnail_uri)) {
        $thumbnail_uri = '';
    }
    //return thumbnail uri
    return $thumbnail_uri;
}
Example #2
0
 *
 * @package Telemark_Skier_Magazine
 */
global $post;
$video = get_field('video_url');
//Embed Code
$alt_poster = get_field('video_poster_frame');
$post_classes = array('feed-post', 'video-feed-post');
// use preg_match to find iframe src
preg_match('/src="(.+?)"/', $video, $matches);
$src = $matches[1];
preg_match('/width="(.+?)"/', $video, $widths);
$width = $widths[1];
preg_match('/height="(.+?)"/', $video, $heights);
$height = $heights[1];
$type = parse_video_uri($src);
$autoplay = $type['type'] == 'youtube' ? '&autoplay=1' : '?autoplay=1';
if (!has_post_thumbnail()) {
    $hero_image_url = $alt_poster;
} else {
    $hero_image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full')[0];
}
?>

<article id="post-<?php 
the_ID();
?>
" <?php 
post_class($post_classes);
?>
 data-id="vid-<?php