function ImageFormatter::settingsSummary

Overrides FormatterBase::settingsSummary

2 calls to ImageFormatter::settingsSummary()
ImageUrlFormatter::settingsSummary in core/modules/image/src/Plugin/Field/FieldFormatter/ImageUrlFormatter.php
Returns a short summary for the current formatter settings.
MediaThumbnailFormatter::settingsSummary in core/modules/media/src/Plugin/Field/FieldFormatter/MediaThumbnailFormatter.php
Returns a short summary for the current formatter settings.
2 methods override ImageFormatter::settingsSummary()
ImageUrlFormatter::settingsSummary in core/modules/image/src/Plugin/Field/FieldFormatter/ImageUrlFormatter.php
Returns a short summary for the current formatter settings.
MediaThumbnailFormatter::settingsSummary in core/modules/media/src/Plugin/Field/FieldFormatter/MediaThumbnailFormatter.php
Returns a short summary for the current formatter settings.

File

core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php, line 139

Class

ImageFormatter
Plugin implementation of the 'image' formatter.

Namespace

Drupal\image\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = [];
  $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.
  $image_style_setting = $this->getSetting('image_style');
  if (isset($image_styles[$image_style_setting])) {
    $summary[] = t('Image style: @style', [
      '@style' => $image_styles[$image_style_setting],
    ]);
  }
  else {
    $summary[] = t('Original image');
  }
  $link_types = [
    'content' => t('Linked to content'),
    'file' => t('Linked to file'),
  ];
  // Display this setting only if image is linked.
  $image_link_setting = $this->getSetting('image_link');
  if (isset($link_types[$image_link_setting])) {
    $summary[] = $link_types[$image_link_setting];
  }
  return $summary;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.