diff --git a/includes/themes/media_youtube.theme.inc b/includes/themes/media_youtube.theme.inc index 84c97cf..8b0fc79 100644 --- a/includes/themes/media_youtube.theme.inc +++ b/includes/themes/media_youtube.theme.inc @@ -30,11 +30,11 @@ function media_youtube_preprocess_media_youtube_video(&$variables) { // These queries default to 0. If the option is true, set value to 1. foreach (array('autoplay', 'enablejsapi', 'loop', 'modestbranding') as $option) { - if ($variables['options'][$option]) { + if (!empty($variables['options'][$option])) { $query[$option] = 1; } } - if ($variables['options']['enablejsapi']) { + if (!empty($variables['options']['enablejsapi'])) { // Add a query ID and identical html ID if js API is set. $query['playerapiid'] = drupal_html_id('media-youtube-' . $variables['video_id']); $variables['api_id_attribute'] = 'id="' . $query['playerapiid'] . '" '; @@ -49,13 +49,13 @@ function media_youtube_preprocess_media_youtube_video(&$variables) { // Currently, loop only works with a playlist. Make fake playlist out of a // single video. // @see https://developers.google.com/youtube/player_parameters#loop - if ($variables['options']['loop']) { + if (!empty($variables['options']['loop'])) { $query['playlist'] = $variables['video_id']; } // These queries default to 1. If the option is false, set value to 0. foreach (array('rel', 'showinfo') as $option) { - if (!$variables['options'][$option]) { + if (empty($variables['options'][$option])) { $query[$option] = 0; } } @@ -65,25 +65,25 @@ function media_youtube_preprocess_media_youtube_video(&$variables) { // (None right now.) // Strings. - if ($variables['options']['theme'] != 'dark') { + if (!empty($variables['options']['theme']) && $variables['options']['theme'] != 'dark') { $query['theme'] = $variables['options']['theme']; } - if ($variables['options']['color'] != 'red') { + if (!empty($variables['options']['color']) && $variables['options']['color'] != 'red') { $query['color'] = $variables['options']['color']; } - if ($variables['options']['autohide'] != '2') { + if (!empty($variables['options']['autohide']) && $variables['options']['autohide'] != '2') { $query['autohide'] = $variables['options']['autohide']; } // Non-query options. - if ($variables['options']['nocookie']) { + if (!empty($variables['options']['nocookie'])) { $url_base = 'youtube-nocookie.com'; } else { $url_base = 'youtube.com'; } - if ($variables['options']['protocol_specify']) { + if (!empty($variables['options']['protocol_specify'])) { $protocol = $variables['options']['protocol']; } else { @@ -92,7 +92,9 @@ function media_youtube_preprocess_media_youtube_video(&$variables) { // Add some options as their own template variables. foreach (array('width', 'height') as $theme_var) { - $variables[$theme_var] = $variables['options'][$theme_var]; + if (isset($variables['options'][$theme_var])) { + $variables[$theme_var] = $variables['options'][$theme_var]; + } } // Do something useful with the overridden attributes from the file