You are here

public function SvgFormatter::settingsSummary in SVG Formatter 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/SvgFormatter.php, line 211

Class

SvgFormatter
Plugin implementation of the 'svg_formatter' formatter.

Namespace

Drupal\svg_formatter\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = [];

  // Implement settings summary.
  if ($this
    ->getSetting('inline')) {
    $summary[] = $this
      ->t('Inline SVG');
  }
  if ($this
    ->getSetting('sanitize')) {
    $summary[] = $this
      ->t('Sanitize inline SVG');
  }
  if ($this
    ->getSetting('apply_dimensions') && $this
    ->getSetting('width')) {
    $summary[] = $this
      ->t('Image width:') . ' ' . $this
      ->getSetting('width');
  }
  if ($this
    ->getSetting('apply_dimensions') && $this
    ->getSetting('height')) {
    $summary[] = $this
      ->t('Image height:') . ' ' . $this
      ->getSetting('height');
  }
  if ($this
    ->getSetting('enable_alt') && !$this
    ->getSetting('inline')) {
    $summary[] = $this
      ->t('Alt enabled');
    if ($this
      ->getSetting('alt_string')) {
      $summary[] = $this
        ->t('Alt token:') . ' ' . $this
        ->getSetting('alt_string');
    }
  }
  if ($this
    ->getSetting('enable_title') && !$this
    ->getSetting('inline')) {
    $summary[] = $this
      ->t('Title enabled');
    if ($this
      ->getSetting('title_string')) {
      $summary[] = $this
        ->t('Title token:') . ' ' . $this
        ->getSetting('title_string');
    }
  }
  return $summary;
}