apply_filters( 'embed_oembed_html', string|false $cache, string $url, array $attr, int $post_ID )

Filters the cached oEmbed HTML.


Top ↑

See also

Top ↑



(string|false) The cached HTML result, stored in post meta.


(string) The attempted embed URL.


(array) An array of shortcode attributes.


(int) Post ID.

Top ↑


File: wp-includes/class-wp-embed.php

View on Trac

Top ↑


Version Description
2.9.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 1 content
    Contributed by swis

    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.

  2. Skip to note 2 content
    Contributed by Matt Radford

    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;
  3. Skip to note 3 content
    Contributed by Ryan Burnette

    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.