/**
 * Allows VideoPress, YouTube, and Vimeo videos to play inline on Facebook
 */
function enhanced_og_video($tags)
{
    if (!is_singular() || post_password_required()) {
        return $tags;
    }
    global $post;
    // Always favor featured images.
    if (enhanced_og_has_featured_image($post->ID)) {
        return $tags;
    }
    $summary = Jetpack_Media_Summary::get($post->ID);
    if ('video' != $summary['type']) {
        if ($summary['count']['video'] > 0 && $summary['count']['image'] < 1) {
            $tags['og:image'] = $summary['image'];
            $tags['og:image:secure_url'] = $summary['secure']['image'];
        }
        return $tags;
    }
    $tags['og:image'] = $summary['image'];
    $tags['og:image:secure_url'] = $summary['secure']['image'];
    // This should be html by default for youtube/vimeo, since we're linking to HTML pages.
    $tags['og:video:type'] = isset($summary['video_type']) ? $summary['video_type'] : 'text/html';
    $video_url = $summary['video'];
    $secure_video_url = $summary['secure']['video'];
    if (preg_match('/((youtube|vimeo)\\.com|youtu.be)/', $video_url)) {
        if (strstr($video_url, 'youtube')) {
            $id = jetpack_get_youtube_id($video_url);
            $video_url = 'http://www.youtube.com/v/' . $id . '?version=3&autohide=1';
            $secure_video_url = 'https://www.youtube.com/v/' . $id . '?version=3&autohide=1';
        } else {
            if (strstr($video_url, 'vimeo')) {
                preg_match('|vimeo\\.com/(\\d+)/?$|i', $video_url, $match);
                $id = (int) $match[1];
                $video_url = 'http://vimeo.com/moogaloop.swf?clip_id=' . $id;
                $secure_video_url = 'https://vimeo.com/moogaloop.swf?clip_id=' . $id;
            }
        }
    }
    $tags['og:video'] = $video_url;
    $tags['og:video:secure_url'] = $secure_video_url;
    if (empty($post->post_title)) {
        $tags['og:title'] = sprintf(__('Video on %s', 'jetpack'), get_option('blogname'));
    }
    return $tags;
}
/**
 * Allows VideoPress, YouTube, and Vimeo videos to play inline on Facebook
 */
function enhanced_og_video($tags)
{
    if (!is_singular()) {
        return $tags;
    }
    global $post;
    // Always favor featured images.
    if (enhanced_og_has_featured_image($post->ID)) {
        return $tags;
    }
    $summary = Jetpack_Media_Summary::get($post->ID);
    if ('video' != $summary['type']) {
        if ($summary['count']['video'] > 0 && $summary['count']['image'] < 1) {
            $tags['og:image'] = $summary['image'];
            $tags['og:image:secure_url'] = $summary['secure']['image'];
        }
        return $tags;
    }
    $tags['og:image'] = $summary['image'];
    $tags['og:image:secure_url'] = $summary['secure']['image'];
    $tags['og:video:type'] = 'application/x-shockwave-flash';
    $video_url = $summary['video'];
    $secure_video_url = $summary['secure']['video'];
    if (preg_match('/((youtube|vimeo)\\.com|youtu.be)/', $video_url)) {
        if (strstr($video_url, 'youtube')) {
            $id = get_youtube_id($video_url);
            $video_url = 'http://www.youtube.com/v/' . $id . '?version=3&autohide=1';
            $secure_video_url = 'https://www.youtube.com/v/' . $id . '?version=3&autohide=1';
        } else {
            if (strstr($video_url, 'vimeo')) {
                preg_match('|vimeo\\.com/(\\d+)/?$|i', $video_url, $match);
                $id = (int) $match[1];
                $video_url = 'http://vimeo.com/moogaloop.swf?clip_id=' . $id;
                $secure_video_url = 'https://vimeo.com/moogaloop.swf?clip_id=' . $id;
            }
        }
    }
    $tags['og:video'] = $video_url;
    $tags['og:video:secure_url'] = $secure_video_url;
    if (empty($post->post_title)) {
        $tags['og:title'] = sprintf(__('Video on %s', 'jetpack'), get_option('blogname'));
    }
    return $tags;
}