You are here

public function OEmbedFormatter::settingsSummary in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/media/src/Plugin/Field/FieldFormatter/OEmbedFormatter.php \Drupal\media\Plugin\Field\FieldFormatter\OEmbedFormatter::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

core/modules/media/src/Plugin/Field/FieldFormatter/OEmbedFormatter.php, line 276

Class

OEmbedFormatter
Plugin implementation of the 'oembed' formatter.

Namespace

Drupal\media\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = parent::settingsSummary();
  if ($this
    ->getSetting('max_width') && $this
    ->getSetting('max_height')) {
    $summary[] = $this
      ->t('Maximum size: %max_width x %max_height pixels', [
      '%max_width' => $this
        ->getSetting('max_width'),
      '%max_height' => $this
        ->getSetting('max_height'),
    ]);
  }
  elseif ($this
    ->getSetting('max_width')) {
    $summary[] = $this
      ->t('Maximum width: %max_width pixels', [
      '%max_width' => $this
        ->getSetting('max_width'),
    ]);
  }
  elseif ($this
    ->getSetting('max_height')) {
    $summary[] = $this
      ->t('Maximum height: %max_height pixels', [
      '%max_height' => $this
        ->getSetting('max_height'),
    ]);
  }
  return $summary;
}