You are here

public function ImageFormatter::settingsSummary in Facebook Instant Articles 3.x

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldFormatter/ImageFormatter.php \Drupal\fb_instant_articles\Plugin\Field\FieldFormatter\ImageFormatter::settingsSummary()

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 ImageFormatter::settingsSummary

File

src/Plugin/Field/FieldFormatter/ImageFormatter.php, line 123

Class

ImageFormatter
Plugin implementation of the 'fbia_image' formatter.

Namespace

Drupal\fb_instant_articles\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');
  }
  if ($this
    ->getSetting('caption')) {
    $summary[] = $this
      ->t('Use alt text as caption');
  }
  if ($presentation = $this
    ->getSetting('presentation')) {
    $summary[] = $this
      ->t('Presentation: @presentation', [
      '@presentation' => $this
        ->presentationLabel($presentation),
    ]);
  }
  return $summary;
}