Created
January 11, 2017 19:04
-
-
Save stellarcowboy/f1670515c15bcafdf7a49e8c3bcfd33e to your computer and use it in GitHub Desktop.
Add URL parameters to YouTube oembed in WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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