You are here

function photoswipe_field_formatter_settings_summary in PhotoSwipe 7.2

Same name and namespace in other branches
  1. 7 photoswipe.module \photoswipe_field_formatter_settings_summary()

Implements hook_field_formatter_settings_summary().

File

./photoswipe.module, line 229
Photswipe integration with Drupal module.

Code

function photoswipe_field_formatter_settings_summary($field, $instance, $view_mode) {
  $display = $instance['display'][$view_mode];
  $settings = $display['settings'];
  $summary = array();
  $image_styles = image_style_options(FALSE);

  // Unset possible 'No defined styles' option.
  unset($image_styles['']);

  // Styles could be lost because of enabled/disabled modules that defines
  // their styles in code.
  if (isset($image_styles[$settings['photoswipe_node_style']])) {
    $summary[] = t('Node image style: @style', array(
      '@style' => $image_styles[$settings['photoswipe_node_style']],
    ));
  }
  else {
    if ($settings['photoswipe_node_style'] == 'hide') {
      $summary[] = t('Node image style: Hide');
    }
    else {
      $summary[] = t('Node image style: Original image');
    }
  }
  if (isset($image_styles[$settings['photoswipe_node_style_first']])) {
    $summary[] = t('Node image style of first image: @style', array(
      '@style' => $image_styles[$settings['photoswipe_node_style_first']],
    ));
  }
  if (isset($image_styles[$settings['photoswipe_image_style']])) {
    $summary[] = t('Photoswipe image style: @style', array(
      '@style' => $image_styles[$settings['photoswipe_image_style']],
    ));
  }
  else {
    $summary[] = t('photoswipe image style: Original image');
  }
  if (isset($settings['photoswipe_caption'])) {
    $caption_options = array(
      'alt' => t('Image Alt Tag'),
      'title' => t('Image Title Tag'),
      'node_title' => t('Node Title'),
    );
    if (array_key_exists($settings['photoswipe_caption'], $caption_options)) {
      $caption_setting = $caption_options[$settings['photoswipe_caption']];
    }
    else {
      $caption_setting = $settings['photoswipe_caption'];
    }
    $summary[] = t('Photoswipe Caption: @field', array(
      '@field' => $caption_setting,
    ));
  }
  else {
    $summary[] = t('Photoswipe Caption: Image Alt Tag');
  }
  return implode('<br />', $summary);
}