You are here

public function SvgImageWidget::settingsSummary in Svg Image 2.x

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldWidget/SvgImageWidget.php \Drupal\svg_image\Plugin\Field\FieldWidget\SvgImageWidget::settingsSummary()
  2. 1.x src/Plugin/Field/FieldWidget/SvgImageWidget.php \Drupal\svg_image\Plugin\Field\FieldWidget\SvgImageWidget::settingsSummary()

Returns a short summary for the current widget settings.

If an empty result is returned, a UI can still be provided to display a settings form in case the widget has configurable settings.

Return value

array A short summary of the widget settings.

Overrides FileWidget::settingsSummary

File

src/Plugin/Field/FieldWidget/SvgImageWidget.php, line 123

Class

SvgImageWidget
Override plugin of the 'image_image' widget.

Namespace

Drupal\svg_image\Plugin\Field\FieldWidget

Code

public function settingsSummary() {
  $summary = parent::settingsSummary();
  $imageStyles = image_style_options(FALSE);

  // Unset possible 'No defined styles' option.
  unset($imageStyles['']);

  // Styles could be lost because of enabled/disabled modules that defines
  // their styles in code.
  $imageStyleSetting = $this
    ->getSetting('preview_image_style');
  if (isset($imageStyles[$imageStyleSetting])) {
    $previewImageStyle = $this
      ->t('Preview image style: @style', [
      '@style' => $imageStyles[$imageStyleSetting],
    ]);
  }
  else {
    $previewImageStyle = $this
      ->t('No preview');
  }
  array_unshift($summary, $previewImageStyle);
  return $summary;
}