Skip to content

Instantly share code, notes, and snippets.

@salcode
Created January 22, 2014 21:36
Show Gist options
  • Save salcode/8567833 to your computer and use it in GitHub Desktop.
Save salcode/8567833 to your computer and use it in GitHub Desktop.
Corrective code for WordPress YouTube oEmbed on a webpage that has CSS transform translate.
<?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