Skip to content

Instantly share code, notes, and snippets.

@tomfinitely
Last active August 29, 2015 14:18
Show Gist options
  • Save tomfinitely/936c11d21e057e100236 to your computer and use it in GitHub Desktop.
Save tomfinitely/936c11d21e057e100236 to your computer and use it in GitHub Desktop.
YouTube oEmbed Filter
// customize embed settings
function custom_youtube_settings($code){
if(strpos($code, 'youtu.be') !== false || strpos($code, 'youtube.com') !== false){
$return = preg_replace("@src=(['\"])?([^'\">\s]*)@", "src=$1$2&showinfo=0&rel=0&autohide=1", $code);
return $return;
}
return $code;
}
add_filter('embed_handler_html', 'custom_youtube_settings');
add_filter('embed_oembed_html', 'custom_youtube_settings');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment