Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save katmoody/62f63415627ac02c54cf to your computer and use it in GitHub Desktop.
Save katmoody/62f63415627ac02c54cf to your computer and use it in GitHub Desktop.
<?php
// add parameter html5=1 to oembed YouTube requests as per
// http://stackoverflow.com/questions/17747443/css-transform-translate-breaking-youtube-embedded-video
// using modified version of code on http://www.alittleofboth.com/2013/06/modifying-youtube-video-display-in-wordpress/
add_filter( 'oembed_result', 'youtube_oembed_html5_parameter', 10, 3);
function youtube_oembed_html5_parameter($data, $url, $args = array()) {
// add &html5=1 parameter
$data = preg_replace('/(youtube\.com.*)(\?feature=oembed)(.*)/', '$1?' . apply_filters("hyrv_extra_querystring_parameters", "feature=oembed&amp;html5=1&amp;") . 'rel=0$3', $data);
return $data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment