Title: embed_oembed_html
Published: April 25, 2014
Last modified: August 20, 2026

---

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

## In this article

 * [Description](https://developer.wordpress.org/reference/hooks/embed_oembed_html/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/hooks/embed_oembed_html/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/hooks/embed_oembed_html/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/embed_oembed_html/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/embed_oembed_html/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/embed_oembed_html/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/hooks/embed_oembed_html/?output_format=md#user-contributed-notes)

Filters the cached oEmbed HTML.

## 󠀁[Description](https://developer.wordpress.org/reference/hooks/embed_oembed_html/?output_format=md#description)󠁿

### 󠀁[See also](https://developer.wordpress.org/reference/hooks/embed_oembed_html/?output_format=md#see-also)󠁿

 * [WP_Embed::shortcode()](https://developer.wordpress.org/reference/classes/WP_Embed/shortcode/)

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/embed_oembed_html/?output_format=md#parameters)󠁿

 `$cache`string

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](https://developer.wordpress.org/reference/hooks/embed_oembed_html/?output_format=md#source)󠁿

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

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-embed.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/class-wp-embed.php#L291)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/class-wp-embed.php#L291-L291)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/embed_oembed_html/?output_format=md#related)󠁿

| Used by | Description | 
| [WP_Embed::shortcode()](https://developer.wordpress.org/reference/classes/wp_embed/shortcode/)`wp-includes/class-wp-embed.php` |

The [do_shortcode()](https://developer.wordpress.org/reference/functions/do_shortcode/) callback function.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/embed_oembed_html/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.9.0](https://developer.wordpress.org/reference/since/2.9.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/hooks/embed_oembed_html/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 5 content](https://developer.wordpress.org/reference/hooks/embed_oembed_html/?output_format=md#comment-content-1964)
 2.    [Matt Radford](https://profiles.wordpress.org/mattrad/)  [  10 years ago  ](https://developer.wordpress.org/reference/hooks/embed_oembed_html/#comment-1964)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fembed_oembed_html%2F%23comment-1964)
     Vote results for this note: 2[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fembed_oembed_html%2F%23comment-1964)
 4.  Wrap oEmbed in a div. Useful for making video responsive, for example.
 5.      ```php
         add_filter( 'embed_oembed_html', 'wrap_oembed_html', 99, 4 );
     
         function wrap_oembed_html( $cached_html, $url, $attr, $post_id ) {
         	if ( false !== strpos( $url, "://youtube.com") || false !== strpos( $url, "://youtu.be" ) ) {
         		$cached_html = '<div class="responsive-video">' . $cached_html . '</div>';
         	}
         	return $cached_html;
         }
         ```
     
 6.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fembed_oembed_html%2F%3Freplytocom%3D1964%23feedback-editor-1964)
 7.   [Skip to note 6 content](https://developer.wordpress.org/reference/hooks/embed_oembed_html/?output_format=md#comment-content-2414)
 8.    [swis](https://profiles.wordpress.org/swis/)  [  9 years ago  ](https://developer.wordpress.org/reference/hooks/embed_oembed_html/#comment-2414)
 9.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fembed_oembed_html%2F%23comment-2414)
     Vote results for this note: 2[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fembed_oembed_html%2F%23comment-2414)
 10. Note that [https://developer.wordpress.org/reference/hooks/embed_oembed_html/#comment-1964](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.
 11. 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.
 12.  * Only want to filter YouTube and Vimeo? User this instead:
      *     ```php
             add_filter( 'embed_oembed_html', 'wpse_embed_oembed_html', 99, 4 );  function wpse_embed_oembed_html( $cache, $url, $attr, $post_ID ) { 	$classes = array(); 	 	// Add these classes to all embeds. 	$classes_all = array( 		'responsive-container', 	); 	 	// Check for different providers and add appropriate classes. 	if ( false !== strpos( $url, 'vimeo.com' ) ) { 		$classes[] = 'vimeo'; 	} 	 	if ( false !== strpos( $url, 'youtube.com' ) ) { 		$classes[] = 'youtube'; 	} 	 	$classes = array_merge( $classes, $classes_all ); 	 	return '' . $cache . ''; } 
            ```
        
      *  Props to Dave Romsey on StackExchange.
      * [Matt Radford](https://profiles.wordpress.org/mattrad/) [9 years ago](https://developer.wordpress.org/reference/hooks/embed_oembed_html/#comment-2639)
 13.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fembed_oembed_html%2F%3Freplytocom%3D2414%23feedback-editor-2414)
 14.  [Skip to note 7 content](https://developer.wordpress.org/reference/hooks/embed_oembed_html/?output_format=md#comment-content-2200)
 15.   [Ryan Burnette](https://profiles.wordpress.org/ryanburnette/)  [  10 years ago  ](https://developer.wordpress.org/reference/hooks/embed_oembed_html/#comment-2200)
 16. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fembed_oembed_html%2F%23comment-2200)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fembed_oembed_html%2F%23comment-2200)
 17. 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](https://github.com/Automattic/jetpack/issues/1571)
 18.  * Use this filter if Jetpack is activated.`add_filter('video_embed_html', 'wrap_embed_html');//
        Jetpack`
      * [Matt Radford](https://profiles.wordpress.org/mattrad/) [9 years ago](https://developer.wordpress.org/reference/hooks/embed_oembed_html/#comment-2638)
 19.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fembed_oembed_html%2F%3Freplytocom%3D2200%23feedback-editor-2200)
 20.  [Skip to note 8 content](https://developer.wordpress.org/reference/hooks/embed_oembed_html/?output_format=md#comment-content-3232)
 21.   [Maya Soloveva](https://profiles.wordpress.org/mayasol/)  [  7 years ago  ](https://developer.wordpress.org/reference/hooks/embed_oembed_html/#comment-3232)
 22. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fembed_oembed_html%2F%23comment-3232)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fembed_oembed_html%2F%23comment-3232)
 23. To wrap oEmbed in a `div` it’s better to use `oembed_dataparse` filter, cause 
     it allows to get parameters of oEmbed, such as type, width and height.
 24.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fembed_oembed_html%2F%3Freplytocom%3D3232%23feedback-editor-3232)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fembed_oembed_html%2F)
before being able to contribute a note or feedback.