apply_filters( 'oembed_dataparse', string $return , object $data , string $url )
Filters the returned oEmbed HTML.
Description Description
Use this filter to add support for custom data types, or to filter the result.
Parameters Parameters
- $return
-
(string) The returned oEmbed HTML.
- $data
-
(object) A data object result from an oEmbed provider.
- $url
-
(string) The URL of the content to be embedded.
Source Source
Changelog Changelog
| Version | Description |
|---|---|
| 2.9.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Can be used to wrap oEmbed response in html, depending on type and size of oEmbed.
function wrap_oembed_dataparse($return, $data, $url) { $mod = ''; if ( ( $data->type == 'video' ) && ( isset($data->width) ) && ( isset($data->height) ) && ( round($data->height/$data->width, 2) == round( 3/4, 2) ) ) { $mod = 'embed-responsive--4-3'; } return '<div class="embed-responsive ' . $mod . '">' . $return . '</div>'; } add_filter( 'oembed_dataparse', 'wrap_oembed_dataparse', 99, 4 );Expand full source codeCollapse full source code
To use ‘oembed_dataparse’ for the first time, you might have to clear oEmbed post-meta cache:
add_filter( 'oembed_ttl', function($ttl) { $GLOBALS['wp_embed']->usecache = 0; $ttl = 0; // House-cleanoing do_action( 'wpse_do_cleanup' ); return $ttl; }); add_filter( 'embed_oembed_discover', function( $discover ) { if( 1 === did_action( 'wpse_do_cleanup' ) ) $GLOBALS['wp_embed']->usecache = 1; return $discover; } );Expand full source codeCollapse full source code