You are here

public function SvgImageFieldFormatter::settingsSummary in SVG Image Field 8

Same name and namespace in other branches
  1. 2.1.x src/Plugin/Field/FieldFormatter/SvgImageFieldFormatter.php \Drupal\svg_image_field\Plugin\Field\FieldFormatter\SvgImageFieldFormatter::settingsSummary()
  2. 2.0.x src/Plugin/Field/FieldFormatter/SvgImageFieldFormatter.php \Drupal\svg_image_field\Plugin\Field\FieldFormatter\SvgImageFieldFormatter::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 FormatterBase::settingsSummary

File

src/Plugin/Field/FieldFormatter/SvgImageFieldFormatter.php, line 119

Class

SvgImageFieldFormatter
Plugin implementation of the 'svg_formatter' formatter.

Namespace

Drupal\svg_image_field\Plugin\Field\FieldFormatter

Code

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

  // Implement settings summary.
  if ($this
    ->getSetting('inline')) {
    $summary[] = $this
      ->t('Inline SVG');
  }
  if ($this
    ->getSetting('apply_dimensions') && $this
    ->getSetting('width')) {
    $summary[] = $this
      ->t('Image width: @width', [
      '@width' => $this
        ->getSetting('width'),
    ]);
  }
  if ($this
    ->getSetting('apply_dimensions') && $this
    ->getSetting('width')) {
    $summary[] = $this
      ->t('Image height: @height', [
      '@height' => $this
        ->getSetting('height'),
    ]);
  }
  if ($this
    ->getSetting('enable_alt')) {
    $summary[] = $this
      ->t('Alt enabled');
  }
  if ($this
    ->getSetting('enable_title')) {
    $summary[] = $this
      ->t('Title enabled');
  }
  $link_types = $this
    ->getLinkTypes();

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