You are here

function template_preprocess_media_youtube_html5 in Media: YouTube 6

File

themes/media_youtube.theme.inc, line 32
Theme functions for Media: YouTube.

Code

function template_preprocess_media_youtube_html5(&$variables) {

  // Merge in our default variables.
  $variables = array_merge($variables, $variables['variables']);
  $variables['fullscreen_value'] = isset($variables['fullscreen_value']) ? $variables['fullscreen_value'] : (media_youtube_variable_get('full_screen') ? 'true' : 'false');
  $variables['width'] = check_plain($variables['width']);
  $variables['height'] = check_plain($variables['height']);
  $variables['fullscreen_value'] = check_plain($variables['fullscreen_value']);
  $variables['iframe_title'] = isset($variables['iframe_title']) ? check_plain($variables['iframe_title']) : t('@title', array(
    '@title' => media_youtube_variable_get('iframe_title'),
  ));
  $variables['classes'] = isset($variables['classes']) ? $variables['classes'] : array(
    'media-youtube-html5',
  );
  $variables['class'] = check_plain(implode(' ', $variables['classes']));

  // Set the 'related videos' youtube option.
  $variables['related'] = isset($variables['related']) ? $variables['related'] : media_youtube_variable_get('show_related_videos');

  // Set the Autoplay option.
  $variables['autoplay'] = isset($variables['autoplay']) ? $variables['autoplay'] : media_youtube_variable_get('autoplay');
  $variables['autoplay'] = $variables['autoplay'] ? '1' : '0';
  $proto = _media_youtube_protocol();
  $variables['url'] = $proto . "www.youtube.com/embed/{$variables['video_id']}";
  $variables['query_defaults'] = array(
    'autoplay' => $variables['autoplay'],
    'rel' => $variables['related'],
    'hd' => '1',
  );

  // Allow us to override the query array if needed.
  $variables['query'] = isset($variables['query']) ? $variables['query'] : array();
  $variables['query'] = array_merge($variables['query_defaults'], $variables['query']);
  $variables['url'] = url($variables['url'], array(
    'query' => $variables['query'],
  ));
}