apply_filters( ’embed_oembed_html’, string|false $cache, string $url, array $attr, int $post_id )

Filters the cached oEmbed HTML.


See also


The cached HTML result, stored in post meta.
The attempted embed URL.
An array of shortcode attributes.
Post ID.


return apply_filters( 'embed_oembed_html', $cache, $url, $attr, $post_id );



User Contributed Notes

  1. Skip to note 5 content

    Wrap oEmbed in a div. Useful for making video responsive, for example.

    add_filter( 'embed_oembed_html', 'wrap_oembed_html', 99, 4 );
    function wrap_oembed_html( $cached_html, $url, $attr, $post_id ) {
    	if ( false !== strpos( $url, "://") || false !== strpos( $url, "://" ) ) {
    		$cached_html = '<div class="responsive-video">' . $cached_html . '</div>';
    	return $cached_html;
  2. Skip to note 6 content

    Note that 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.

  3. Skip to note 7 content

    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.

You must log in before being able to contribute a note or feedback.