video_image_url_by_guid

Get the image URL for the given VideoPress GUID.

Description

(string) video_image_url_by_guid( (string) $guid, (string) $format ); 

We look up by GUID, because that is what WPCOM does and this needs to be parameter compatible with that.

Note: This mimics the WPCOM function of the same name and helps the media API endpoint add all needed VideoPress data.

Returns (string)

Parameters (2)

0. $guid (string)
The guid.
1. $format (string)
The format.

Usage

  1. if ( !function_exists( 'video_image_url_by_guid' ) ) { 
  2. require_once '/modules/videopress/utility-functions.php'; 
  3.  
  4. // The guid. 
  5. $guid = ''; 
  6.  
  7. // The format. 
  8. $format = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = video_image_url_by_guid($guid, $format); 
  12.  

Defined (1)

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

/modules/videopress/utility-functions.php  
  1. function video_image_url_by_guid( $guid, $format ) { 
  2.  
  3. $post = video_get_post_by_guid( $guid ); 
  4.  
  5. if ( is_wp_error( $post ) ) { 
  6. return null; 
  7.  
  8. $meta = wp_get_attachment_metadata( $post->ID ); 
  9.  
  10. // We add ssl => 1 to make sure that the videos.files.wordpress.com domain is parsed as photon. 
  11. $poster = apply_filters( 'jetpack_photon_url', $meta['videopress']['poster'], array( 'ssl' => 1 ), 'https' ); 
  12.  
  13. return $poster;