Last active
July 12, 2017 22:30
-
-
Save amielucha/d23fb0663b3af0565bb9 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