You are here

public function ImagecacheExternalImage::settingsSummary in Imagecache External 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 FormatterBase::settingsSummary

File

src/Plugin/Field/FieldFormatter/ImagecacheExternalImage.php, line 109

Class

ImagecacheExternalImage
Plugin implementation of the 'imagecache_external_image' formatter.

Namespace

Drupal\imagecache_external\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = parent::settingsSummary();
  $settings = $this
    ->getSettings();
  $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['imagecache_external_style']])) {
    $summary[] = t('Image style: @style', [
      '@style' => $image_styles[$settings['imagecache_external_style']],
    ]);
  }
  else {
    $summary[] = t('Original image');
  }
  $link_types = [
    'content' => t('Linked to content'),
    'file' => t('Linked to cached file'),
  ];

  // Display this setting only if image is linked.
  if (isset($link_types[$settings['imagecache_external_link']])) {
    $summary[] = $link_types[$settings['imagecache_external_link']];
  }
  return $summary;
}