I was trying to enable the JavaScript API for an embedded youtube-player. It means that I somehow needed to add `&enablejsapi=1` to all youtube oEmbed url. When searching around I found a filter called `oembed_result`. Help from this article I found a solution I wanted.
`
function my_plugin_enable_js_api( $html, $url, $args ) {
/* Modify video parameters. */
if ( strstr( $html,’youtube.com/embed/’ ) ) {
$html = str_replace( ‘?feature=oembed’, ‘?feature=oembed&enablejsapi=1’, $html );
}
return $html;
}
add_filter( ‘oembed_result’, ‘my_plugin_enable_js_api’, 10, 3 );
`
The code is pretty simple. If oEmbed is youtube video add argument `enablejsapi=1` to url to enable API. Let me know if there is easier way to do it.