BP_Core_oEmbed_Extension::get_oembed_response_data( array $item, int $width )
Fetch our oEmbed response data to return.
Description
A simplified version of get_oembed_response_data().
Parameters
- $item
-
(Required) Custom oEmbed response data.
- $width
-
(Required) The requested width.
Return
(array)
Source
File: bp-core/classes/class-bp-core-oembed-extension.php
protected function get_oembed_response_data( $item, $width ) { $data = wp_parse_args( $item, array( 'version' => '1.0', 'provider_name' => get_bloginfo( 'name' ), 'provider_url' => get_home_url(), 'author_name' => get_bloginfo( 'name' ), 'author_url' => get_home_url(), 'title' => ucfirst( $this->slug_endpoint ), 'type' => 'rich', ) ); /** This filter is documented in /wp-includes/embed.php */ $min_max_width = apply_filters( 'oembed_min_max_width', array( 'min' => 200, 'max' => 600 ) ); $width = min( max( $min_max_width['min'], $width ), $min_max_width['max'] ); $height = max( ceil( $width / 16 * 9 ), 200 ); $data['width'] = absint( $width ); $data['height'] = absint( $height ); // Set 'html' parameter. if ( 'video' === $data['type'] || 'rich' === $data['type'] ) { // Fake a WP post so we can use get_post_embed_html(). $post = new stdClass; $post->post_content = $data['content']; $post->post_title = $data['title']; $data['html'] = get_post_embed_html( $data['width'], $data['height'], $post ); } // Remove temporary parameters. unset( $data['content'] ); return $data; }
Changelog
Version | Description |
---|---|
BuddyPress 2.6.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.