apply_filters( 'embed_oembed_html', string|false $cache , string $url , array $attr , int $post_id )
Filters the cached oEmbed HTML.
Contents
Description
See also
Parameters
-
$cache
string|false -
The cached HTML result, stored in post meta.
-
$url
string -
The attempted embed URL.
-
$attr
array -
An array of shortcode attributes.
-
$post_id
int -
Post ID.
Source
File: wp-includes/class-wp-embed.php
.
View all references
return apply_filters( 'embed_oembed_html', $cache, $url, $attr, $post_id );
Changelog
Version | Description |
---|---|
2.9.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.
Wrap oEmbed in a div. Useful for making video responsive, for example.
Note that https://developer.wordpress.org/reference/hooks/embed_oembed_html/#comment-1964 very incorrectly assumes that every oEmbed response contains a video, and even more incorrect raises the expectation that every oEmbed response has the same aspect-ratio.
Please never copy/paste the example as-is into your theme. Especially not when the theme is intended to be re-used/sold. It is killing oEmbed.
Top ↑
Feedback
Only want to filter YouTube and Vimeo? User this instead:
Props to Dave Romsey on StackExchange. — By Matt Radford —
I wish I had known before I implemented code on this hook that JetPack overrides and doesn’t reimplement the filter. If you hook anything to this be sure you won’t be using JetPack or it won’t work. https://github.com/Automattic/jetpack/issues/1571
Top ↑
Feedback
Use this filter if Jetpack is activated.
add_filter('video_embed_html', 'wrap_embed_html'); // Jetpack
— By Matt Radford —To wrap oEmbed in a
div
it’s better to useoembed_dataparse
filter, cause it allows to get parameters of oEmbed, such as type, width and height.