-
-
Save jcicero518/6a127125562a6db7ea55c91bd60d2c99 to your computer and use it in GitHub Desktop.
WordPress oEmbed filters
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
// usage on page: | |
// echo wp_oembed_get('https://www.youtube.com/watch?v=123qweasd', array('width'=>458, 'autoplay'=>0, 'rel'=>0, 'showinfo'=>0 )); | |
// add parameters to oembed | |
add_filter('oembed_result','lc_oembed_result', 10, 3); | |
function lc_oembed_result($html, $url, $args) { | |
// $args includes custom argument | |
$newargs = $args; | |
// get rid of discover=true argument | |
array_pop( $newargs ); | |
$parameters = http_build_query( $newargs ); | |
// Modify video parameters | |
$html = str_replace( '?feature=oembed', '?feature=oembed'.'&'.$parameters, $html ); | |
return $html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment