enhanced_og_video

Allows VideoPress, YouTube, and Vimeo videos to play inline on Facebook.

Description

enhanced_og_video( $tags ); 

Parameters (1)

0. $tags
The tags.

Usage

  1. if ( !function_exists( 'enhanced_og_video' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'jetpack-by-wordpress-com/modules/publicize/enhanced-open-graph.php'; 
  3.  
  4. // The tags. 
  5. $tags = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = enhanced_og_video($tags); 
  9.  

Defined (1)

The function is defined in the following location(s).

/modules/publicize/enhanced-open-graph.php  
  1. function enhanced_og_video( $tags ) { 
  2. if ( !is_singular() || post_password_required() ) 
  3. return $tags; 
  4.  
  5. global $post; 
  6.  
  7. // Always favor featured images. 
  8. if ( enhanced_og_has_featured_image( $post->ID ) ) 
  9. return $tags; 
  10.  
  11. $summary = Jetpack_Media_Summary::get( $post->ID ); 
  12.  
  13. if ( 'video' != $summary['type'] ) { 
  14. if ( $summary['count']['video'] > 0 && $summary['count']['image'] < 1 ) { 
  15. $tags['og:image'] = $summary['image']; 
  16. $tags['og:image:secure_url'] = $summary['secure']['image']; 
  17. return $tags; 
  18.  
  19. $tags['og:image'] = $summary['image']; 
  20. $tags['og:image:secure_url'] = $summary['secure']['image']; 
  21. $tags['og:video:type'] = 'application/x-shockwave-flash'; 
  22.  
  23. $video_url = $summary['video']; 
  24. $secure_video_url = $summary['secure']['video']; 
  25.  
  26. if ( preg_match( '/((youtube|vimeo)\.com|youtu.be)/', $video_url ) ) { 
  27. if ( strstr( $video_url, 'youtube' ) ) { 
  28. $id = jetpack_get_youtube_id( $video_url ); 
  29. $video_url = 'http://www.youtube.com/v/' . $id . '?version=3&autohide=1'; 
  30. $secure_video_url = 'https://www.youtube.com/v/' . $id . '?version=3&autohide=1'; 
  31. } else if ( strstr( $video_url, 'vimeo' ) ) { 
  32. preg_match( '|vimeo\.com/(\d+)/?$|i', $video_url, $match ); 
  33. $id = (int) $match[1]; 
  34. $video_url = 'http://vimeo.com/moogaloop.swf?clip_id=' . $id; 
  35. $secure_video_url = 'https://vimeo.com/moogaloop.swf?clip_id=' . $id; 
  36.  
  37. $tags['og:video'] = $video_url; 
  38. $tags['og:video:secure_url'] = $secure_video_url; 
  39.  
  40. if ( empty( $post->post_title ) ) 
  41. $tags['og:title'] = sprintf( __( 'Video on %s', jetpack ), get_option( 'blogname' ) ); 
  42.  
  43. return $tags;