Due to a requirement of the client, I’ve had to modify the oembed code to autoplay videos. While this works great on the front-end, every instance of oEmbeds in the backend autoplays videos. This is the function I have in Functions.php…
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'].'?autoplay=1&vq=hd1080&rel=0&showinfo=0" frameborder="0" allowfullscreen></iframe>';
}
return $html;
}
add_filter('oembed_result','Oembed_youtube_no_title',10,3);
What do I need to do to keep the front-end functionality while keeping the video from auto-playing in the backend? Thanks!
nevermind, fixed it with an if (is_admin())