You are here

function juicebox_field_formatter_settings_form in Juicebox HTML5 Responsive Image Galleries 7.2

Same name and namespace in other branches
  1. 7 juicebox.module \juicebox_field_formatter_settings_form()

Implements hook_field_formatter_settings_form().

File

includes/juicebox.field.inc, line 78
Contains all hooks and related methods for the juicebox_formatter field formatter.

Code

function juicebox_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {

  // We need a Juicbox object to fetch some common configuration details.
  $juicebox = juicebox();
  $form = array();

  // Detect if this is a "pseudo" instance such that the field's context is
  // managed by something other than the core Field API (e.g., a fake ctools
  // instance used for a panel or a view row). This case is supported but we
  // still want to put up a notice about it.
  if (!isset($instance['id'])) {
    $form['instance_warning'] = array(
      '#prefix' => '<div class="messages warning">',
      '#markup' => t('<strong>WARNING:</strong> You appear to be using the Juicebox field formatter with a field instance that is not directly attached to an entity. Support for this configuration is currently experimental. Please test your final gallery output thoroughly.'),
      '#suffix' => '</div>',
    );
  }

  // Get available title and caption sources.
  $text_sources = _juicebox_field_text_sources($instance);

  // Get available image style presets
  $settings = $instance['display'][$view_mode]['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' => $juicebox
      ->confBaseStylePresets(),
    '#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' => $juicebox
      ->confBaseStylePresets(FALSE),
    '#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 value that should be used for the caption.'),
    '#options' => $text_sources,
    '#empty_option' => t('No caption'),
  );
  $form['title_source'] = array(
    '#type' => 'select',
    '#title' => t('Title Source'),
    '#default_value' => $settings['title_source'],
    '#description' => t('The image value that should be used for the title.'),
    '#options' => $text_sources,
    '#empty_option' => t('No title'),
  );

  // Add common Juicebox form options.
  $form = $juicebox
    ->confBaseForm($form, $settings);
  return $form;
}