You are here

public function CollageFormatter::settingsSummary in Collage Formatter 8

Returns a short summary for the current formatter settings.

If an empty result is returned, a UI can still be provided to display a settings form in case the formatter has configurable settings.

Return value

string[] A short summary of the formatter settings.

Overrides ImageFormatter::settingsSummary

File

src/Plugin/Field/FieldFormatter/CollageFormatter.php, line 304
Contains \Drupal\collageformatter\src\Plugin\Field\FieldFormatter\CollageFormatter.

Class

CollageFormatter
Plugin implementation of the 'collageformatter' formatter.

Namespace

Drupal\collageformatter\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $settings = $this
    ->getSettings();
  $summary[] = t('Generate') . t('<strong>') . $settings['collage_number'] . t('</strong> ') . t('collage(s)') . ' ' . t('with') . ' <strong>' . ($settings['images_per_collage'] ? $settings['images_per_collage'] : t('all')) . '</strong> ' . t('image(s) per collage') . '; ' . t('Skip') . ' <strong>' . $settings['images_to_skip'] . '</strong> ' . t('image(s) from the start');
  $summary[] = t('Collage orientation') . ': ' . ($settings['collage_orientation'] ? t('Portrait') : t('Landscape'));
  $summary[] = t('Collage width') . ': ' . ($settings['collage_width'] ? $settings['collage_width'] . 'px' : t('Not set'));
  $summary[] = t('Collage height') . ': ' . ($settings['collage_height'] ? $settings['collage_height'] . 'px' : t('Not set'));
  $summary[] = t('Collage border') . ': ' . $settings['collage_border_size'] . 'px <span style="background-color: ' . $settings['collage_border_color'] . ';">' . $settings['collage_border_color'] . '</span>';
  $summary[] = t('Image gap') . ': ' . $settings['gap_size'] . 'px <span style="background-color: ' . $settings['gap_color'] . ';">' . $settings['gap_color'] . '</span>';
  $summary[] = t('Image border') . ': ' . $settings['border_size'] . 'px <span style="background-color: ' . $settings['border_color'] . ';">' . $settings['border_color'] . '</span>';
  $link_types = [
    'content' => t('Images linked to content'),
    'file' => t('Images linked to file'),
  ];
  if (!empty($link_types[$settings['image_link']])) {
    $summary[] = $link_types[$settings['image_link']];
    if ($settings['image_link'] == 'file') {
      if (empty($settings['image_link_image_style'])) {
        $summary[] = t('Target image style') . ': ' . t('None (Original Image)');
      }
      else {
        $image_styles = image_style_options(FALSE);
        $summary[] = t('Target image style') . ': ' . $image_styles[$settings['image_link_image_style']];
      }

      // Modal gallery summary
      if (empty($settings['image_link_modal'])) {
        $summary[] = t('Modal gallery') . ': ' . t('None');
      }
      else {
        $summary[] = t('Modal gallery') . ': ' . $settings['image_link_modal'];
      }

      // Custom class/rel summary.
      $custom = [];
      if (!empty($settings['image_link_class'])) {
        $custom[] = 'class="' . Html::escape($settings['image_link_class']) . '"';
      }
      if (!empty($settings['image_link_rel'])) {
        $custom[] = 'rel="' . Html::escape($settings['image_link_rel']) . '"';
      }
      $summary[] = implode(' ', $custom);
    }
  }
  else {
    $summary[] = t('Images without links');
  }
  if ($settings['generate_image_derivatives']) {
    $summary[] = t('Generate image derivatives');
  }
  else {
    $summary[] = t('Do not generate image derivatives');
  }
  if ($settings['prevent_upscale']) {
    $summary[] = t('Prevent images upscaling');
  }
  return $summary;
}