You are here

function youtube_colorbox_youtube_thumbnail_field_formatter_settings_alter in YouTube Field 7

Implements hook_youtube_thumbnail_field_formatter_settings_alter().

File

modules/youtube_colorbox/youtube_colorbox.module, line 49
Provides Colorbox support to YouTube Field display settings.

Code

function youtube_colorbox_youtube_thumbnail_field_formatter_settings_alter(&$element, $instance, $settings, $field_name) {
  $colorbox = $settings[YOUTUBE_COLORBOX_LINK_TYPE];

  // Set the states input name variable. JS states functionality will otherwise
  // break in Panels if the entity type is 'ctools'.
  $input_name = 'fields[' . $field_name . '][settings_edit_form][settings][image_link]';
  $input_name = $instance['entity_type'] != 'ctools' ? $input_name : 'image_link';

  // Setting elements.
  $element[YOUTUBE_COLORBOX_LINK_TYPE] = array(
    '#type' => 'fieldset',
    '#title' => t('Colorbox Settings'),
    '#states' => array(
      'visible' => array(
        ':input[name="' . $input_name . '"]' => array(
          'value' => YOUTUBE_COLORBOX_LINK_TYPE,
        ),
      ),
    ),
    '#tree' => TRUE,
  );
  $element[YOUTUBE_COLORBOX_LINK_TYPE]['parameters'] = array(
    '#type' => 'fieldset',
    '#title' => t('Parameters'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $element[YOUTUBE_COLORBOX_LINK_TYPE]['parameters']['width'] = array(
    '#type' => 'textfield',
    '#title' => t('Width'),
    '#size' => 5,
    '#required' => TRUE,
    '#field_suffix' => 'px',
    '#default_value' => $colorbox['parameters']['width'],
    '#element_validate' => array(
      'youtube_colorbox_element_is_int',
    ),
  );
  $element[YOUTUBE_COLORBOX_LINK_TYPE]['parameters']['height'] = array(
    '#type' => 'textfield',
    '#title' => t('Height'),
    '#size' => 5,
    '#required' => TRUE,
    '#field_suffix' => 'px',
    '#default_value' => $colorbox['parameters']['height'],
    '#element_validate' => array(
      'youtube_colorbox_element_is_int',
    ),
  );
  $element[YOUTUBE_COLORBOX_LINK_TYPE]['parameters']['autoplay'] = array(
    '#type' => 'checkbox',
    '#title' => t('Play video automatically when loaded (autoplay).'),
    '#default_value' => $colorbox['parameters']['autoplay'],
    '#return_value' => 1,
  );
  $element[YOUTUBE_COLORBOX_LINK_TYPE]['parameters']['mute'] = array(
    '#type' => 'checkbox',
    '#title' => t('Mute video by default when loaded (mute).'),
    '#default_value' => $colorbox['parameters']['mute'],
    '#return_value' => 1,
  );
  $element[YOUTUBE_COLORBOX_LINK_TYPE]['parameters']['loop'] = array(
    '#type' => 'checkbox',
    '#title' => t('Loop the playback of the video (loop).'),
    '#default_value' => $colorbox['parameters']['loop'],
    '#return_value' => 1,
  );
  $element[YOUTUBE_COLORBOX_LINK_TYPE]['parameters']['controls'] = array(
    '#type' => 'checkbox',
    '#title' => t('Always hide video controls (controls).'),
    '#default_value' => $colorbox['parameters']['controls'],
    '#return_value' => 1,
  );
  $element[YOUTUBE_COLORBOX_LINK_TYPE]['parameters']['autohide'] = array(
    '#type' => 'checkbox',
    '#title' => t('Hide video controls after play begins (autohide).'),
    '#default_value' => $colorbox['parameters']['autohide'],
    '#return_value' => 1,
  );
  $element[YOUTUBE_COLORBOX_LINK_TYPE]['parameters']['iv_load_policy'] = array(
    '#type' => 'checkbox',
    '#title' => t('Hide video annotations by default (iv_load_policy).'),
    '#default_value' => $colorbox['parameters']['iv_load_policy'],
    '#return_value' => 3,
  );
  $element[YOUTUBE_COLORBOX_LINK_TYPE]['gallery'] = array(
    '#type' => 'checkbox',
    '#title' => t('Group all videos on the page into a gallery'),
    '#default_value' => $colorbox['gallery'],
  );
}