You are here

public function PdfThumbnail::settingsSummary in PDF 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/PdfThumbnail.php, line 49

Class

PdfThumbnail
Plugin annotation @FieldFormatter( id = "pdf_thumbnail", label = @Translation("PDF: Display the first page"), description = @Translation("Display the first page of the PDF file."), field_types = {"file"} )

Namespace

Drupal\pdf\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = [];
  $scale = $this
    ->getSetting('scale');
  $width = $this
    ->getSetting('width');
  $height = $this
    ->getSetting('height');
  if (empty($scale) && empty($width) && empty($height)) {
    $summary[] = $this
      ->t('No settings');
  }
  else {
    $summary[] = t('Scale: @scale, Width: @width, Height: @height', [
      '@scale' => $scale,
      '@width' => $width,
      '@height' => $height,
    ]);
  }
  return $summary;
}