Making WordPress.org


Ignore:
Timestamp:
11/04/2015 10:01:23 PM (9 years ago)
Author:
iandunn
Message:

WordPress.tv: Embed MP4 videos in Facebook posts instead of Flash.

Fixes #1375
Props kraftbj

Location:
sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/plugins/wordpresstv-open-graph
Files:
1 copied
1 moved

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/plugins/wordpresstv-open-graph/wordpresstv-open-graph.php

    r2037 r2038  
    11<?php
    22
    3 namespace WordPressTV\TwitterCards;
     3namespace WordPressTV\OpenGraph;
    44
    55/*
    66 * Register hook callbacks
    77 */
    8 add_filter( 'jetpack_open_graph_tags', __NAMESPACE__ . '\add_player_tags', 11 ); // after wpcom_twitter_cards_tags
     8add_filter( 'jetpack_open_graph_tags', __NAMESPACE__ . '\customize_open_graph_tags', 11 ); // after wpcom_twitter_cards_tags
    99
    1010/**
    11  * Add tags that are necessary for videos to be embedded into tweets
     11 * Customize each post's Open Graph tags for WPTV
    1212 */
    13 function add_player_tags( $og_tags ) {
     13function customize_open_graph_tags( $og_tags ) {
    1414    global $post;
    1515
     
    2525    }
    2626
    27     // Add the tags necessary for the player
     27    // Make WPTV videos embeddable in Twitter player cards
    2828    $video_info = video_get_info_by_guid( $video_id[0] );
    2929    list( $width, $height ) = wp_expand_dimensions( $video_info->width, $video_info->height, 560, 315 );
     30    $mp4_url = set_url_scheme( wp_get_attachment_url( $video_info->post_id ), 'https' );
    3031
    3132    $og_tags['twitter:card']                       = 'player';
     
    3334    $og_tags['twitter:player:width']               = $width;
    3435    $og_tags['twitter:player:height']              = $height;
    35     $og_tags['twitter:player:stream']              = wp_get_attachment_url( $video_info->post_id );
     36    $og_tags['twitter:player:stream']              = $mp4_url;
    3637    $og_tags['twitter:player:stream:content_type'] = 'video/mp4';
     38
     39    /*
     40     * Embed MP4 videos in Facebook posts instead of the Flash player
     41     *
     42     * @todo: This can be removed once https://github.com/Automattic/jetpack/issues/2950 is fixed
     43     */
     44    $og_tags['og:video:type']                      = 'video/mp4';
     45    $og_tags['og:video']                           = $mp4_url;
     46    $og_tags['og:video:secure_url']                = $mp4_url;
    3747
    3848    return $og_tags;
Note: See TracChangeset for help on using the changeset viewer.