function ResponsiveImageFormatter::settingsSummary

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

Overrides FormatterBase::settingsSummary

File

core/modules/responsive_image/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php, line 195

Class

ResponsiveImageFormatter
Plugin for responsive image formatter.

Namespace

Drupal\responsive_image\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
    $summary = [];
    $responsive_image_style = $this->responsiveImageStyleStorage
        ->load($this->getSetting('responsive_image_style'));
    if ($responsive_image_style) {
        $summary[] = $this->t('Responsive image style: @responsive_image_style', [
            '@responsive_image_style' => $responsive_image_style->label(),
        ]);
        $link_types = [
            'content' => $this->t('Linked to content'),
            'file' => $this->t('Linked to file'),
        ];
        // Display this setting only if image is linked.
        if (isset($link_types[$this->getSetting('image_link')])) {
            $summary[] = $link_types[$this->getSetting('image_link')];
        }
    }
    else {
        $summary[] = $this->t('Select a responsive image style.');
    }
    $image_loading = $this->getSetting('image_loading');
    $summary[] = $this->t('Loading attribute: @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.