Skip to content

Instantly share code, notes, and snippets.

@amielucha
Last active July 12, 2017 22:30
Show Gist options
  • Save amielucha/d23fb0663b3af0565bb9 to your computer and use it in GitHub Desktop.
Save amielucha/d23fb0663b3af0565bb9 to your computer and use it in GitHub Desktop.
WordPress oEmbed filters
// 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