function ImageWidget::settingsSummary

Same name in other branches
  1. 9 core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php \Drupal\image\Plugin\Field\FieldWidget\ImageWidget::settingsSummary()
  2. 8.9.x core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php \Drupal\image\Plugin\Field\FieldWidget\ImageWidget::settingsSummary()
  3. 10 core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php \Drupal\image\Plugin\Field\FieldWidget\ImageWidget::settingsSummary()

Overrides FileWidget::settingsSummary

File

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

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 = $this->t('Preview image style: @style', [
            '@style' => $image_styles[$image_style_setting],
        ]);
    }
    else {
        $preview_image_style = $this->t('No preview');
    }
    array_unshift($summary, $preview_image_style);
    return $summary;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.