Created
January 22, 2014 21:36
-
-
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.
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
<?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&html5=1&") . 'rel=0$3', $data); | |
return $data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment