Skip to content

Instantly share code, notes, and snippets.

@caralgar
Created November 23, 2015 11:29
Show Gist options
  • Save caralgar/79f07b4b6856345818cb to your computer and use it in GitHub Desktop.
Save caralgar/79f07b4b6856345818cb to your computer and use it in GitHub Desktop.
Remove youtube controls, info & related videos
<?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&amp;") . 'rel=0';
//Regular oembed
if (strpos($data, "feature=oembed") !== false) {
$data = str_replace('feature=oembed', $str_to_add . '&amp;feature=oembed', $data);
//Playlist
} elseif (strpos($data, "list=") !== false) {
$data = str_replace('list=', $str_to_add . '&amp;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