You are here

public function SliderProFormatter::settingsSummary in Slider Pro 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 ImageFormatter::settingsSummary

File

src/Plugin/Field/FieldFormatter/SliderProFormatter.php, line 115

Class

SliderProFormatter
Plugin annotation @FieldFormatter( id = "slider_pro", label = @Translation("Slider Pro"), field_types = { "image" } )

Namespace

Drupal\slider_pro\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = [];
  $image_styles = image_style_options(FALSE);
  $optionset = SliderPro::load($this
    ->getSetting('optionset'));
  $summary[] = $this
    ->t('Optionset: @optionset', [
    '@optionset' => $optionset
      ->label(),
  ]);

  // 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[] = $this
      ->t('Image style: @style', [
      '@style' => $image_styles[$image_style_setting],
    ]);
  }
  else {
    $summary[] = $this
      ->t('Image style: Original image');
  }
  $image_style_thumb_setting = $this
    ->getSetting('image_style_thumb');
  if (isset($image_styles[$image_style_thumb_setting])) {
    $summary[] = $this
      ->t('Image style thumbnail: @style', [
      '@style' => $image_styles[$image_style_thumb_setting],
    ]);
  }
  else {
    $summary[] = $this
      ->t('Image style thumbnail: Original image');
  }
  return $summary;
}