You are here

public function AutoImageStyleMediaResponsive::settingsSummary in Auto image style 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 ResponsiveImageFormatter::settingsSummary

File

src/Plugin/Field/FieldFormatter/AutoImageStyleMediaResponsive.php, line 90

Class

AutoImageStyleMediaResponsive
Plugin for responsive media image formatter.

Namespace

Drupal\auto_image_style\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = [];
  $responsive_landscape_image_style = $this->responsiveImageStyleStorage
    ->load($this
    ->getSetting('responsive_image_style_landscape'));
  if ($responsive_landscape_image_style) {
    $summary[] = $this
      ->t('Responsive landscape image style: @responsive_image_style', [
      '@responsive_image_style' => $responsive_landscape_image_style
        ->label(),
    ]);
  }
  else {
    $summary[] = $this
      ->t('Select a responsive landscape image style.');
  }
  $responsive_portrait_image_style = $this->responsiveImageStyleStorage
    ->load($this
    ->getSetting('responsive_image_style_portrait'));
  if ($responsive_portrait_image_style) {
    $summary[] = $this
      ->t('Responsive portrait image style: @responsive_image_style', [
      '@responsive_image_style' => $responsive_portrait_image_style
        ->label(),
    ]);
  }
  else {
    $summary[] = $this
      ->t('Select a responsive portrait image style.');
  }
  $link_types = [
    'content' => $this
      ->t('Linked to content'),
    'file' => $this
      ->t('Linked to file'),
  ];

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