Created
November 23, 2015 11:29
-
-
Save caralgar/79f07b4b6856345818cb to your computer and use it in GitHub Desktop.
Remove youtube controls, info & related videos
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 | |
// Based on Hide YouTube Related Videos plugin for WordPress | |
// Ocultar videos relacionados en youtube | |
add_filter('oembed_result', 'hide_youtube_related_videos', 10, 3); | |
function hide_youtube_related_videos($data, $url, $args = array()) { | |
//Setup the string to inject into the url | |
$str_to_add = apply_filters("hyrv_extra_querystring_parameters", "wmode=transparent&") . 'rel=0'; | |
//Regular oembed | |
if (strpos($data, "feature=oembed") !== false) { | |
$data = str_replace('feature=oembed', $str_to_add . '&feature=oembed', $data); | |
//Playlist | |
} elseif (strpos($data, "list=") !== false) { | |
$data = str_replace('list=', $str_to_add . '&list=', $data); | |
} | |
//All Set | |
return $data; | |
} | |
// Filtro para no mostrar controles e informacion | |
add_filter("hyrv_extra_querystring_parameters", "my_hyrv_extra_querystring_parameters"); | |
function my_hyrv_extra_querystring_parameters($str) { | |
return "wmode=transparent&controls=0&showinfo=0&"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment