Filter for wp_embed_handler_youtube not working

In Wordpress 4.0, if I create a new post and paste a YouTube link directly into the post editor, Wordpress will automatically convert it to a YouTube embed tag. I'm trying to edit the default output for the embed tag with a filter function.

I have a snippet set up like this:

add_action( '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.

Topic youtube filters Wordpress

Category Web


a little late, but it might be because this is a filter, and you're adding it as an action,

try

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;
}

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.