You are here

public function BackgroundImageFormatter::settingsSummary in Simple Background image formatter 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 ImageFormatter::settingsSummary

File

src/Plugin/Field/FieldFormatter/BackgroundImageFormatter.php, line 78

Class

BackgroundImageFormatter
Plugin implementation of the background_image_formatter.

Namespace

Drupal\background_image_formatter\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = [];
  $image_styles = image_style_options(FALSE);
  unset($image_styles['']);
  $select_style = $this
    ->getSetting('image_style');
  if (isset($image_styles[$select_style])) {
    $summary[] = $this
      ->t('URL for image style: @style', [
      '@style' => $image_styles[$select_style],
    ]);
  }
  else {
    $summary[] = $this
      ->t('Original image');
  }
  $summary[] = $this
    ->t('Output type: @output_type', [
    '@output_type' => $this
      ->getSetting('background_image_output_type'),
  ]);
  $summary[] = $this
    ->t('The CSS selector <code>@background_image_selector</code> will be created with the image set to the background-image property.', [
    '@background_image_selector' => $this
      ->getSetting('background_image_selector') . '_id',
  ]);
  return $summary;
}