You are here

function media_youtube_file_formatter_video_settings in Media: YouTube 7.3

Same name and namespace in other branches
  1. 7 includes/media_youtube.formatters.inc \media_youtube_file_formatter_video_settings()
  2. 7.2 includes/media_youtube.formatters.inc \media_youtube_file_formatter_video_settings()

Implements hook_file_formatter_FORMATTER_settings().

1 string reference to 'media_youtube_file_formatter_video_settings'
media_youtube_file_formatter_info in includes/media_youtube.formatters.inc
Implements hook_file_formatter_info().

File

includes/media_youtube.formatters.inc, line 81
File formatters for YouTube videos.

Code

function media_youtube_file_formatter_video_settings($form, &$form_state, $settings) {
  $element = array();
  $element['width'] = array(
    '#title' => t('Width'),
    '#type' => 'textfield',
    '#default_value' => $settings['width'],
    '#element_validate' => array(
      '_youtube_validate_video_width_and_height',
    ),
  );
  $element['height'] = array(
    '#title' => t('Height'),
    '#type' => 'textfield',
    '#default_value' => $settings['height'],
    '#element_validate' => array(
      '_youtube_validate_video_width_and_height',
    ),
  );

  // @see https://developers.google.com/youtube/player_parameters#Parameters
  // Multiple options.
  $element['theme'] = array(
    '#title' => t('Player theme'),
    '#type' => 'radios',
    '#options' => array(
      'dark' => t('Dark'),
      'light' => t('Light'),
    ),
    '#default_value' => $settings['theme'],
  );
  $element['color'] = array(
    '#title' => t('Progress bar color'),
    '#type' => 'radios',
    '#options' => array(
      'red' => t('Red'),
      'white' => t('White'),
    ),
    '#default_value' => $settings['color'],
  );
  $element['autohide'] = array(
    '#title' => t('Controls during playback'),
    '#type' => 'radios',
    '#options' => array(
      '0' => t('Keep progress bar and player controls on screen while playing'),
      '2' => t('Hide progress bar while playing'),
      '1' => t('Hide progress bar and player controls'),
    ),
    '#default_value' => $settings['autohide'],
  );
  $element['captions'] = array(
    '#title' => t('Captions displaying options'),
    '#type' => 'radios',
    '#options' => array(
      '0' => t('Turns captions off by default'),
      '1' => t('Turns captions on by default'),
      '2' => t('Turns captions on and set the caption language for the video by default'),
    ),
    '#default_value' => $settings['captions'],
  );

  // Single Options.
  $element['autoplay'] = array(
    '#title' => t('Autoplay video on load'),
    '#type' => 'checkbox',
    '#default_value' => $settings['autoplay'],
  );
  $element['loop'] = array(
    '#title' => t('Loop video'),
    '#type' => 'checkbox',
    '#default_value' => $settings['loop'],
  );
  $element['controls'] = array(
    '#title' => t('Show Controls'),
    '#type' => 'checkbox',
    '#default_value' => $settings['controls'],
  );

  // Note: make sure the positive/negative language lines up with option
  // processing in media_youtube.theme.inc.
  $element['showinfo'] = array(
    '#title' => t('Display video title and uploader'),
    '#type' => 'checkbox',
    '#default_value' => $settings['showinfo'],
  );
  $element['modestbranding'] = array(
    '#title' => t('Remove YouTube logo from the control bar'),
    '#type' => 'checkbox',
    '#default_value' => $settings['modestbranding'],
  );
  $element['rel'] = array(
    '#title' => t('Show related videos when playback ends'),
    '#type' => 'checkbox',
    '#default_value' => $settings['rel'],
  );
  $element['nocookie'] = array(
    '#title' => t('Use privacy enhanced (no cookie) mode'),
    '#type' => 'checkbox',
    '#default_value' => $settings['nocookie'],
  );
  $element['protocol_specify'] = array(
    '#title' => t('Specify an http protocol'),
    '#type' => 'checkbox',
    '#default_value' => $settings['protocol_specify'],
    '#description' => t('An explicit protocol may be necessary for videos embedded in RSS feeds and emails. If no protocol is specified, iframes will be protocol relative.'),
  );
  $element['protocol'] = array(
    '#title' => t('Iframe protocol'),
    '#type' => 'radios',
    '#default_value' => 'https:',
    '#options' => array(
      'https:' => 'https://',
    ),
    '#states' => array(
      'invisible' => array(
        ':input[name="displays[media_youtube_video][settings][protocol_specify]"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );

  // JS api.
  $element['enablejsapi'] = array(
    '#title' => t('Enable the <a href="https://developers.google.com/youtube/js_api_reference">Javascript API</a>'),
    '#type' => 'checkbox',
    '#default_value' => $settings['enablejsapi'],
    '#description' => 'An id in the format <code>media-youtube-{video_id}</code> will be added to each iframe.',
  );
  $element['origin'] = array(
    '#title' => t('Origin'),
    '#type' => 'textfield',
    '#description' => t('If the Javascript API is enabled, enter your site\'s domain for added security.'),
    '#default_value' => $settings['origin'],
    '#states' => array(
      'invisible' => array(
        ':input[name="displays[media_youtube_video][settings][enablejsapi]"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
    '#element_validate' => array(
      '_youtube_validate_jsapi_domain',
    ),
  );
  return $element;
}