You are here

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

Class

AutoImageStyleResponsive
Plugin annotation @FieldFormatter( id = "auto_image_style_responsive", label = @Translation("Responsive image auto orientation"), description = @Translation("Display responsive image fields as portrait or landscape style"), field_types = { …

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.');
  }
  return $summary;
}