You are here

public function ImagecacheExternalResponsiveImage::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/ImagecacheExternalResponsiveImage.php, line 177

Class

ImagecacheExternalResponsiveImage
Plugin implementation of the 'imagecache_external_image' formatter.

Namespace

Drupal\imagecache_external\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = [];
  $responsive_image_style = $this->responsiveImageStyleStorage
    ->load($this
    ->getSetting('imagecache_external_responsive_style'));
  if ($responsive_image_style) {
    $summary[] = t('Responsive image style: @responsive_image_style', [
      '@responsive_image_style' => $responsive_image_style
        ->label(),
    ]);
    $link_types = [
      'content' => t('Linked to content'),
      'file' => t('Linked to file'),
    ];

    // Display this setting only if image is linked.
    if (isset($link_types[$this
      ->getSetting('imagecache_external_link')])) {
      $summary[] = $link_types[$this
        ->getSetting('imagecache_external_link')];
    }
  }
  else {
    $summary[] = t('Select a responsive image style.');
  }
  return $summary;
}