Support » Plugins » filter hook for built-in oEmbed providers (e.g. youtube)

  • I am looking for a way to add the title of a youtube video ABOVE the embedded youtube code when using oEmbed functionality in wordpress.

    I am also open to using the [embed] shortcode and add custom title attribute there.

    Ive been tearing my hear out all day trying to get a working function filter for oembed that can read custom attributes or custom values from the returned xml/json.

    Any ideas?

    Im currently trying to access the $data object from the filter hook: oembed_dataparse:

    // You can use this filter to add support for custom data types or to filter the result
    return apply_filters( 'oembed_dataparse', $return, $data, $url );

    But I am not having any success.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Just by posting my question, i was somehow able to figure this out.

    Here’s an example.

    $foo = new ExampleWrapper_Oembed;
    class ExampleWrapper_Oembed {
    	/* Here's our filter function. */
    	function add_wrapper( $return, $data, $url ) {
            	$data is an object created by the xml/json returned from the original oEmbed request. 
                Some other youtube fields:
                Each oembed provider will have different fields here, so check for specifics:
        	/* So lets check for the youtube video title. */
    		if( strlen($data->title) > 0 )
    			return $titlebar = '<div class="title">' . $data->title . '</div>' . $return;
    			// we found one, so create some html and prepend it to $result which is the resulting html output.
    		return $return;
        /* adding the filter function to the oembed_dataparse filter hook */
    	function ExampleWrapper_Oembed() {
    		add_filter('oembed_dataparse', array(&$this,'add_wrapper'), 10, 3);

    Hi notroon,

    since you tried something similar as I do, maybe you can help me out. Did your code actually work?

    If so, I’d be glad if you could have a look at my problem here:


    I managed to achive my task by using the embed_oembed_html-filter – see

    Thanks, anyway! 😀

    Thanks saphod, I tried a bunch too, and only embed_oembed_html worked.

    Thanks mate!

    nootron, if you’re still there, can you help me with implementing the code you posted? I can’t get it to work– nothing gets added to the wrapper. Where am I supposed to add the code you added?


Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘filter hook for built-in oEmbed providers (e.g. youtube)’ is closed to new replies.