Skip to content

Instantly share code, notes, and snippets.

@stellarcowboy
Created January 11, 2017 19:04
Show Gist options
  • Save stellarcowboy/f1670515c15bcafdf7a49e8c3bcfd33e to your computer and use it in GitHub Desktop.
Save stellarcowboy/f1670515c15bcafdf7a49e8c3bcfd33e to your computer and use it in GitHub Desktop.
Add URL parameters to YouTube oembed in WordPress
/**
* youtube_embed_url_parameters function.
*
* @access public
* @param string $html
* @param string $url
* @param array $args
* @return string $html
*/
function youtube_embed_url_parameters( $html, $url, $args ) {
/* Modify video parameters. */
if ( strstr( $html,'youtube.com/embed/' ) ) {
$html = str_replace( '?feature=oembed', '?feature=oembed&rel=0&controls=0&showinfo=0', $html );
}
return $html;
}
add_filter( 'oembed_result', 'youtube_embed_url_parameters', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment