You are here

public function ImageWidget::settingsSummary in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php \Drupal\image\Plugin\Field\FieldWidget\ImageWidget::settingsSummary()
  2. 9 core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php \Drupal\image\Plugin\Field\FieldWidget\ImageWidget::settingsSummary()

File

core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php, line 89

Class

ImageWidget
Plugin implementation of the 'image_image' widget.

Namespace

Drupal\image\Plugin\Field\FieldWidget

Code

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

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

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