You are here

function lightgallery_field_formatter_settings_form in Lightgallery 7

Implements hook_field_formatter_settings_form().

File

includes/lightgallery.field.inc, line 52
Contains all hooks and related methods for the lightgallery_formatter field formatter.

Code

function lightgallery_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $image_styles = image_style_options(FALSE);
  $element['image_styles']['lightgallery_image_style'] = array(
    '#title' => t('Lightgallery image style'),
    '#type' => 'select',
    '#default_value' => $settings['image_styles']['lightgallery_image_style'],
    '#empty_option' => t('None (original image)'),
    '#options' => $image_styles,
    '#description' => t('Light gallery image style.'),
  );
  $element['image_styles']['lightgallery_image_thumb_style'] = array(
    '#title' => t('Content image style'),
    '#type' => 'select',
    '#default_value' => $settings['image_styles']['lightgallery_image_thumb_style'],
    '#empty_option' => t('None (original image)'),
    '#options' => $image_styles,
    '#description' => t('Content image style.'),
  );

  // Core options.
  $element['lightgallery_core'] = array(
    '#type' => 'fieldset',
    '#title' => t('Lightgallery core settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $element['lightgallery_core']['mode'] = array(
    '#type' => 'select',
    '#title' => t('Transition'),
    '#options' => _lightgallery_get_modes(),
    '#default_value' => $settings['lightgallery_core']['mode'],
    '#description' => t('Type of transition between images.'),
  );
  $element['lightgallery_core']['preload'] = array(
    '#type' => 'select',
    '#title' => t('Preload'),
    '#options' => drupal_map_assoc(array(
      1,
      2,
      3,
      4,
    )),
    '#default_value' => $settings['lightgallery_core']['preload'],
    '#description' => t('number of preload slides. will exicute only after the current slide is fully loaded.'),
  );
  $element['lightgallery_core']['closable'] = array(
    '#type' => 'checkbox',
    '#title' => t('Closable'),
    '#default_value' => $settings['lightgallery_core']['closable'],
    '#description' => t('Allows clicks on dimmer to close gallery.'),
  );
  $element['lightgallery_core']['loop'] = array(
    '#type' => 'checkbox',
    '#title' => t('Loop'),
    '#default_value' => $settings['lightgallery_core']['loop'],
    '#description' => t('If not selected, the ability to loop back to the beginning of the gallery when on the last element, will be disabled.'),
  );
  $element['lightgallery_core']['esc_key'] = array(
    '#type' => 'checkbox',
    '#title' => t('Escape key'),
    '#default_value' => $settings['lightgallery_core']['esc_key'],
    '#description' => t('Whether the LightGallery could be closed by pressing the "Esc" key.'),
  );
  $element['lightgallery_core']['key_press'] = array(
    '#type' => 'checkbox',
    '#title' => t('Keyboard'),
    '#default_value' => $settings['lightgallery_core']['key_press'],
    '#description' => t('Enable keyboard navigation.'),
  );
  $element['lightgallery_core']['controls'] = array(
    '#type' => 'checkbox',
    '#title' => t('Controls'),
    '#default_value' => $settings['lightgallery_core']['controls'],
    '#description' => t('If not checked, prev/next buttons will not be displayed.'),
  );
  $element['lightgallery_core']['mouse_wheel'] = array(
    '#type' => 'checkbox',
    '#title' => t('Mouse wheel'),
    '#default_value' => $settings['lightgallery_core']['mouse_wheel'],
    '#description' => t('Chane slide on mousewheel'),
  );
  $element['lightgallery_core']['download'] = array(
    '#type' => 'checkbox',
    '#title' => t('Download'),
    '#default_value' => $settings['lightgallery_core']['download'],
    '#description' => t('Enable download button. ' . 'By default download url will be taken from data-src/href attribute but it supports only for modern browsers.'),
  );
  $element['lightgallery_core']['counter'] = array(
    '#type' => 'checkbox',
    '#title' => t('Counter'),
    '#default_value' => $settings['lightgallery_core']['counter'],
    '#description' => t('Whether to show total number of images and index number of currently displayed image.'),
  );
  $element['lightgallery_core']['drag'] = array(
    '#type' => 'checkbox',
    '#title' => t('Drag'),
    '#default_value' => $settings['lightgallery_core']['drag'],
    '#description' => t('Enables desktop mouse drag support.'),
  );
  $element['lightgallery_core']['touch'] = array(
    '#type' => 'checkbox',
    '#title' => t('Touch'),
    '#default_value' => $settings['lightgallery_core']['touch'],
    '#description' => t('Enables touch support.'),
  );
  $element['lightgallery_core']['selector'] = array(
    '#type' => 'textfield',
    '#title' => t('Item selector'),
    '#default_value' => $settings['lightgallery_core']['selector'],
    '#description' => t('CSS item selector for custom layouts.'),
  );

  // Thumb options.
  $element['lightgallery_thumbs'] = array(
    '#type' => 'fieldset',
    '#title' => t('Lightgallery thumbnail settings'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $element['lightgallery_thumbs']['thumbnails'] = array(
    '#type' => 'checkbox',
    '#title' => t('Use thumbnails'),
    '#default_value' => $settings['lightgallery_thumbs']['thumbnails'],
    '#description' => t('Indicate if you want to use thumbnails in the LightGallery.'),
  );
  $element['lightgallery_thumbs']['animate_thumb'] = array(
    '#type' => 'checkbox',
    '#title' => t('Animate thumbnails'),
    '#default_value' => $settings['lightgallery_thumbs']['animate_thumb'],
    '#description' => t('Enable thumbnail animation.'),
  );
  $element['lightgallery_thumbs']['current_pager_position'] = array(
    '#type' => 'select',
    '#title' => t('Position'),
    '#options' => array(
      'left' => t('Left'),
      'middle' => t('Middle'),
      'right' => t('Right'),
    ),
    '#default_value' => $settings['lightgallery_thumbs']['current_pager_position'],
    '#description' => t('Position of selected thumbnail.'),
  );
  $element['lightgallery_thumbs']['thumb_width'] = array(
    '#type' => 'textfield',
    '#title' => t('Width'),
    '#default_value' => $settings['lightgallery_thumbs']['thumb_width'],
    '#description' => t('Width of each thumbnails.'),
  );
  $element['lightgallery_thumbs']['thumb_cont_height'] = array(
    '#type' => 'textfield',
    '#title' => t('Height'),
    '#default_value' => $settings['lightgallery_thumbs']['thumb_cont_height'],
    '#description' => t('Height of the thumbnail container including padding and border.'),
  );
  return $element;
}