#30660 closed defect (bug) (invalid)
Embed handler filter callback not firing (e.g. wp_embed_handler_youtube)
| Reported by: | eterps | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Embeds | Version: | 4.0 |
| Severity: | normal | Keywords: | close |
| Cc: | Focuses: | ui, administration |
Description
I'm trying to create a filter for the new auto-embed feature in Wordpress 4.0 and edit the default output for the embed tag with a filter function.
I have a snippet set up like this in my theme's function.php:
add_filter( 'wp_embed_handler_youtube', 'bigger_youtube_embeds', 10, 4);
function bigger_youtube_embeds($embed, $attr, $url, $rawattr) {
// alter the $embed string...
return $embed;
}
I tried this after viewing the following documentation: https://developer.wordpress.org/reference/hooks/wp_embed_handler_youtube/
My filter function never runs, though, and I'm not even sure when it is supposed to run. I've tried setting Xdebug breakpoints inside the filter function, and using var_dump, and returning a gibberish string ('hello world') from the callback, but nothing ever happens.
Steps to reproduce:
- add a filter or action (I've tried both) for wp_embed_handler_youtube and define a callback.
- Create a new post and paste in a YouTube URL.
- The auto-embed code will run and create an embedded video.
- Save the post
- View the post
At no point in this process did my filter callback ever get called.
My Env:
- Ubuntu 12.04
- PHP 5.4.34
- Wordpress 4.0.1
- Client: Mac OS X + Chrome 39 / Firefox 34
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
The description for the
wp_embed_handler_youtubefilter is misleading. This only filters the embed code for YouTube URLs which start withyoutube.com/embedrather then the normal video URLs which start withyoutube.com/watch.Most likely the filter you're looking for is oembed_result which filters the markup for the embed after it's returned from the provider.
Also note that the auto-embed functionality isn't new in WordPress, it's been there years. The new functionality in 4.0 adds additional support for
youtube.com/embedURLs (#24660).