If you’re embedding videos into WordPress, possibly as a post, you may sometimes want to add parameters to the code to overwrite the oEmbed default behaviour of WordPress.
This can be achieved by creating your own plugin or adding this snippet to your functions.php file. This example removes the related videos at the end of the video (rel=0) although other usual parameters can also be applied, such as autoplay, showinfo etc.
function Oembed_youtube_no_title($html,$url,$args){
$url_string = parse_url($url, PHP_URL_QUERY);
parse_str($url_string, $id);
if (isset($id['v'])) {
return '<iframe width="'.$args['width'].'" height="'.$args['height'].'" src="http://www.youtube.com/embed/'.$id['v'].'?rel=0" frameborder="0" allowfullscreen></iframe>';
}
return $html;
}
add_filter('oembed_result','Oembed_youtube_no_title',10,3);
Thanks. Just needs to be updated to https:// for today’s world. Thanks for the easy bit of code.