I’m trying to add parameters to vimeo video’s that are embedden via WordPress’ oembed. I’ve managed to do this for youtube video’s with the code below. I use this function in functions.php and it works like a charm. I’ve edited the code to do the same for Vimeo video’s, but I can’t seem to make it work.
This is my code:
function Oembed_vimeo_no_title($html,$url,$args){
// Only run this for vimeo embeds
if ( !strstr($url, 'vimeo.com') )
return $html;
$url_string = parse_url($url, PHP_URL_QUERY);
parse_str($url_string, $id);
if (isset($id['v'])) {
return '<div id="video_full_width"><iframe width="100%" height="394" src="//player.vimeo.com/video/'.$id['v'].'?title=0&byline=0&portrait=0" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen ></iframe></div>';
}
return $html;
}
add_filter('oembed_result','Oembed_vimeo_no_title',10,3);
Any suggestion on what I’m doing wrong?
I find that a better way to do it is on the
oembed_fetch_url
filter hook, like so:More details in my other answer here: https://stackoverflow.com/a/55053642/799327