You are here

public function ImageSizesFormatter::settingsSummary in Picture 8

Returns a short summary for the current formatter settings.

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

Return value

string[] A short summary of the formatter settings.

Overrides FormatterBase::settingsSummary

File

src/Plugin/Field/FieldFormatter/ImageSizesFormatter.php, line 96
Contains \Drupal\picture\Plugin\field\formatter\ImageSizesFormatter.

Class

ImageSizesFormatter
Plugin for image with sizes attribute formatter.

Namespace

Drupal\picture\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = array();
  $summary[] = $this
    ->t('Sizes: @sizes', array(
    '@sizes' => $this
      ->getSetting('sizes'),
  ));
  $image_styles = image_style_options(FALSE);
  unset($image_styles['']);
  $image_styles[RESPONSIVE_IMAGE_EMPTY_IMAGE] = $this
    ->t('Empty image');
  $selected_styles = array_filter($this
    ->getSetting('image_styles'));
  $summary[] = t('Image styles: @styles', array(
    '@styles' => implode(', ', array_intersect_key($image_styles, $selected_styles)),
  ));
  $summary[] = t('Fallback image style: @style', array(
    '@style' => $image_styles[$this
      ->getSetting('fallback_image_style')],
  ));
  $link_types = array(
    'content' => t('Linked to content'),
    'file' => 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')];
  }
  return $summary;
}