diff --git a/includes/media_youtube.formatters.inc b/includes/media_youtube.formatters.inc index 6219f02..0124b21 100644 --- a/includes/media_youtube.formatters.inc +++ b/includes/media_youtube.formatters.inc @@ -15,6 +15,7 @@ function media_youtube_file_formatter_info() { 'width' => media_youtube_variable_get('width'), 'height' => media_youtube_variable_get('height'), 'autoplay' => media_youtube_variable_get('autoplay'), + 'related' => 1, ), 'view callback' => 'media_youtube_file_formatter_video_view', 'settings callback' => 'media_youtube_file_formatter_video_settings', @@ -42,7 +43,7 @@ function media_youtube_file_formatter_video_view($file, $display, $langcode) { '#theme' => 'media_youtube_video', '#uri' => $file->uri, ); - foreach (array('width', 'height', 'autoplay') as $setting) { + foreach (array('width', 'height', 'autoplay', 'related') as $setting) { $element['#' . $setting] = isset($file->override[$setting]) ? $file->override[$setting] : $display['settings'][$setting]; } return $element; @@ -69,6 +70,11 @@ function media_youtube_file_formatter_video_settings($form, &$form_state, $setti '#type' => 'checkbox', '#default_value' => $settings['autoplay'], ); + $element['related'] = array( + '#title' => t('Show suggested videos when the video finishes'), + '#type' => 'checkbox', + '#default_value' => $settings['related'], + ); return $element; } diff --git a/includes/themes/media_youtube.theme.inc b/includes/themes/media_youtube.theme.inc index 2f4bf23..121257e 100644 --- a/includes/themes/media_youtube.theme.inc +++ b/includes/themes/media_youtube.theme.inc @@ -19,6 +19,7 @@ function media_youtube_preprocess_media_youtube_video(&$variables) { $variables['width'] = isset($variables['width']) ? $variables['width'] : media_youtube_variable_get('width'); $variables['height'] = isset($variables['height']) ? $variables['height'] : media_youtube_variable_get('height'); $variables['autoplay'] = isset($variables['autoplay']) ? $variables['autoplay'] : media_youtube_variable_get('autoplay'); + $variables['related'] = isset($variables['related']) ? $variables['related'] : 1; $variables['fullscreen'] = isset($variables['fullscreen']) ? $variables['fullscreen'] : media_youtube_variable_get('fullscreen'); $variables['autoplay'] = $variables['autoplay'] ? 1 : 0; $variables['fullscreen'] = $variables['fullscreen'] ? 'true' : 'false'; @@ -53,6 +54,9 @@ OUTPUT; 'autoplay' => $variables['autoplay'], ); } + if ($variables['related'] === 0) { + $settings['media_youtube'][$variables['wrapper_id']]['options']['rel'] = $variables['related']; + } drupal_add_js($settings, 'setting'); drupal_add_js(drupal_get_path('module', 'media_youtube') . '/js/media_youtube.js'); drupal_add_css(drupal_get_path('module', 'media_youtube') . '/css/media_youtube.css'); diff --git a/media_youtube.module b/media_youtube.module index 071812c..1aee88e 100644 --- a/media_youtube.module +++ b/media_youtube.module @@ -69,7 +69,7 @@ function media_youtube_theme($existing, $type, $theme, $path) { 'path' => $path . '/includes/themes', ), 'media_youtube_video' => array( - 'variables' => array('uri' => NULL, 'width' => NULL, 'height' => NULL, 'autoplay' => NULL, 'fullscreen' => NULL), + 'variables' => array('uri' => NULL, 'width' => NULL, 'height' => NULL, 'autoplay' => NULL, 'fullscreen' => NULL, 'related' => NULL), 'file' => 'media_youtube.theme.inc', 'path' => $path . '/includes/themes', 'template' => 'media-youtube-video',