enhanced_og_gallery

Better OG Image Tags for Gallery Post Formats.

Description

enhanced_og_gallery( $tags ); 

Parameters (1)

0. $tags
The tags.

Usage

  1. if ( !function_exists( 'enhanced_og_gallery' ) ) { 
  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_gallery($tags); 
  9.  

Defined (1)

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

/modules/publicize/enhanced-open-graph.php  
  1. function enhanced_og_gallery( $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 ( 'gallery' != $summary['type'] ) 
  14. return $tags; 
  15.  
  16. if( !isset( $summary['images'] ) || !is_array( $summary['images'] ) || empty( $summary['images'] ) ) 
  17. return $tags; 
  18.  
  19. $images = $secures = array(); 
  20. foreach ( $summary['images'] as $i => $image ) { 
  21. $images[] = $image['url']; 
  22. $secures[] = $summary['secure']['images'][$i]['url']; 
  23.  
  24. $tags['og:image'] = $images; 
  25. $tags['og:image:secure_url'] = $secures; 
  26.  
  27. return $tags;