You are here

function juicebox_field_formatter_settings_form in Juicebox HTML5 Responsive Image Galleries 7

Same name and namespace in other branches
  1. 7.2 includes/juicebox.field.inc \juicebox_field_formatter_settings_form()

Implements hook_field_formatter_settings_form().

File

./juicebox.module, line 911
Provides Drupal integration with the Juicebox library.

Code

function juicebox_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  if (!empty($instance['bundle']) && $instance['bundle'] == 'ctools') {
    return array(
      'juicebox_formatter_notice' => array(
        '#prefix' => '<p>',
        '#markup' => t('<strong>NOTICE: The Juicebox field formatter is not fully supported within individual view rows (and other ctools contexts)</strong>. Using this setting is not recommended. For views support please use the Juicebox display style plugin.'),
        '#suffix' => '</p>',
      ),
    );
  }
  $form = array();

  // Get available image style presets
  $presets = image_style_options(FALSE);

  // Initialize the "settings" values before working with them. This is
  // required for legacy support.
  $settings = _juicebox_init_display_settings($instance['display'][$view_mode]['settings']);
  $form = _juicebox_common_form_elements($form, $settings);

  // Add the field-formatter-specific elements.
  $form['image_style'] = array(
    '#type' => 'select',
    '#title' => t('Main Image Style'),
    '#default_value' => $settings['image_style'],
    '#description' => t('The style formatter for the main image.'),
    '#options' => $presets,
    '#empty_option' => t('None (original image)'),
  );
  $form['thumb_style'] = array(
    '#type' => 'select',
    '#title' => t('Thumbnail Style'),
    '#default_value' => $settings['thumb_style'],
    '#description' => t('The style formatter for the thumbnail.'),
    '#options' => $presets,
    '#empty_option' => t('None (original image)'),
  );
  $form['caption_source'] = array(
    '#type' => 'select',
    '#title' => t('Caption Source'),
    '#default_value' => $settings['caption_source'],
    '#description' => t('The image field value that should be used for the caption. This value will be processed with your fallback text format.'),
    '#options' => array(
      'alt' => t('Alternate text'),
      'title' => t('Title'),
    ),
    '#empty_option' => t('No caption'),
  );
  $form['title_source'] = array(
    '#type' => 'select',
    '#title' => t('Title Source'),
    '#default_value' => $settings['title_source'],
    '#description' => t('The image field value that should be used for the title. This value will be processed with your fallback text format.'),
    '#options' => array(
      'alt' => t('Alternate text'),
      'title' => t('Title'),
    ),
    '#empty_option' => t('No title'),
  );
  return $form;
}