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
Use this filter if Jetpack is activated.add_filter('video_embed_html', 'wrap_embed_html'); // Jetpack
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.
Props to Dave Romsey on StackExchange.
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
add_filter('video_embed_html', 'wrap_embed_html'); // Jetpack
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.