get_oembed_response_data_rich

Filters the oEmbed response data to return an iframe embed code.

Description

(array) get_oembed_response_data_rich( (array) $data, (WP_Post) $post, (int) $width, (int) $height ); 

Returns (array)

The modified response data.

Parameters (4)

0. $data (array)
The response data.
1. $post (WP_Post)
The post object.
2. $width (int)
The requested width.
3. $height (int)
The calculated height.

Usage

  1. if ( !function_exists( 'get_oembed_response_data_rich' ) ) { 
  2. require_once ABSPATH . WPINC . '/embed.php'; 
  3.  
  4. // The response data. 
  5. $data = array(); 
  6.  
  7. // The post object. 
  8. $post = null; 
  9.  
  10. // The requested width. 
  11. $width = -1; 
  12.  
  13. // The calculated height. 
  14. $height = -1; 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = get_oembed_response_data_rich($data, $post, $width, $height); 
  18.  

Defined (1)

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

/wp-includes/embed.php  
  1. function get_oembed_response_data_rich( $data, $post, $width, $height ) { 
  2. $data['width'] = absint( $width ); 
  3. $data['height'] = absint( $height ); 
  4. $data['type'] = 'rich'; 
  5. $data['html'] = get_post_embed_html( $width, $height, $post ); 
  6.  
  7. // Add post thumbnail to response if available. 
  8. $thumbnail_id = false; 
  9.  
  10. if ( has_post_thumbnail( $post->ID ) ) { 
  11. $thumbnail_id = get_post_thumbnail_id( $post->ID ); 
  12.  
  13. if ( 'attachment' === get_post_type( $post ) ) { 
  14. if ( wp_attachment_is_image( $post ) ) { 
  15. $thumbnail_id = $post->ID; 
  16. } else if ( wp_attachment_is( 'video', $post ) ) { 
  17. $thumbnail_id = get_post_thumbnail_id( $post ); 
  18. $data['type'] = 'video'; 
  19.  
  20. if ( $thumbnail_id ) { 
  21. list( $thumbnail_url, $thumbnail_width, $thumbnail_height ) = wp_get_attachment_image_src( $thumbnail_id, array( $width, 99999 ) ); 
  22. $data['thumbnail_url'] = $thumbnail_url; 
  23. $data['thumbnail_width'] = $thumbnail_width; 
  24. $data['thumbnail_height'] = $thumbnail_height; 
  25.  
  26. return $data;