Wordpress - wp_embed_register_handler not working

I modified the example you posted from the Codex:

/**
 * Embed support for Forbes videos
 *
 * Usage Example:
 *
 *     http://www.forbes.com/video/5049647995001/
 */
add_action( 'init', function()
{
    wp_embed_register_handler( 
        'forbes', 
        '#http://www\.forbes\.com/video/([\d]+)/?#i', 
        'wp_embed_handler_forbes' 
    );

} );

function wp_embed_handler_forbes( $matches, $attr, $url, $rawattr )
{
    $embed = sprintf(
        '<iframe class="forbes-video" src="https://players.brightcove.net/2097119709001/598f142b-5fda-4057-8ece-b03c43222b3f_default/index.html?videoId=%1$s" width="600" height="400" frameborder="0" scrolling="no"></iframe>',
        esc_attr( $matches[1] ) 
     );

    return apply_filters( 'embed_forbes', $embed, $matches, $attr, $url, $rawattr );
}

Currently the iframe has a fixed height and width.

You can hopefully adjust it to your needs, e.g. using the theme's $content_width or pass on the height/width information directly from the pasted video url.

Update: I added a warning to the Codex page, until a better example is posted.

Tags:

Embed