function ImageFormatter::settingsSummary

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

Overrides FormatterBase::settingsSummary

1 method overrides ImageFormatter::settingsSummary()
MediaThumbnailFormatter::settingsSummary in core/modules/media/src/Plugin/Field/FieldFormatter/MediaThumbnailFormatter.php
Returns a short summary for the current formatter settings.

File

core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php, line 176

Class

ImageFormatter
Plugin implementation of the 'image' formatter.

Namespace

Drupal\image\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
    $summary = [];
    $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('image_style');
    if (isset($image_styles[$image_style_setting])) {
        $summary[] = $this->t('Image style: @style', [
            '@style' => $image_styles[$image_style_setting],
        ]);
    }
    else {
        $summary[] = $this->t('Original image');
    }
    $link_types = [
        'content' => $this->t('Linked to content'),
        'file' => $this->t('Linked to file'),
    ];
    // Display this setting only if image is linked.
    $image_link_setting = $this->getSetting('image_link');
    if (isset($link_types[$image_link_setting])) {
        $summary[] = $link_types[$image_link_setting];
    }
    $image_loading = $this->getSetting('image_loading');
    $summary[] = $this->t('Image loading: @attribute', [
        '@attribute' => $image_loading['attribute'],
    ]);
    return array_merge($summary, parent::settingsSummary());
}

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