You are here

public function ImagecacheProportionsFormatter::settingsSummary in Imagecache Proportions 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/ImagecacheProportionsFormatter.php, line 79
Contains \Drupal\imagecache_proportions\Plugin\Field\FieldFormatter.

Class

ImagecacheProportionsFormatter
Plugin implementation of the 'imagecache_proportions' formatter.

Namespace

Drupal\imagecache_proportions\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = array();
  $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_portrait_setting = $this
    ->getSetting('image_style_portrait');
  if (isset($image_styles[$image_style_portrait_setting])) {
    $summary[] = $this
      ->t('Portrait image style: @style', array(
      '@style' => $image_styles[$image_style_portrait_setting],
    ));
  }
  else {
    $summary[] = $this
      ->t('Original portrait image');
  }
  $image_style_landscape_setting = $this
    ->getSetting('image_style_landscape');
  if (isset($image_styles[$image_style_landscape_setting])) {
    $summary[] = $this
      ->t('Landscape image style: @style', array(
      '@style' => $image_styles[$image_style_landscape_setting],
    ));
  }
  else {
    $summary[] = $this
      ->t('Landscape horizontal image');
  }
  $image_style_setting = $this
    ->getSetting('image_style');
  if (isset($image_styles[$image_style_setting])) {
    $summary[] = $this
      ->t('Squared image style: @style', array(
      '@style' => $image_styles[$image_style_setting],
    ));
  }
  else {
    $summary[] = $this
      ->t('Original squared image');
  }
  $summary[] = $this
    ->t('Looseness: @number px.', array(
    '@number' => $this
      ->getSetting('looseness'),
  ));
  $parent_summary = parent::settingsSummary();
  $summary[] = $parent_summary[1];
  return $summary;
}