public function PhotoswipeFieldFormatter::settingsSummary in PhotoSwipe 8
Same name and namespace in other branches
- 8.2 src/Plugin/Field/FieldFormatter/PhotoswipeFieldFormatter.php \Drupal\photoswipe\Plugin\Field\FieldFormatter\PhotoswipeFieldFormatter::settingsSummary()
- 3.x src/Plugin/Field/FieldFormatter/PhotoswipeFieldFormatter.php \Drupal\photoswipe\Plugin\Field\FieldFormatter\PhotoswipeFieldFormatter::settingsSummary()
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/ PhotoswipeFieldFormatter.php, line 103
Class
- PhotoswipeFieldFormatter
- Plugin implementation of the 'photoswipe_field_formatter' formatter.
Namespace
Drupal\photoswipe\Plugin\Field\FieldFormatterCode
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.
if (isset($image_styles[$this
->getSetting('photoswipe_node_style')])) {
$summary[] = $this
->t('Node image style: @style', [
'@style' => $image_styles[$this
->getSetting('photoswipe_node_style')],
]);
}
elseif ($this
->getSetting('photoswipe_node_style') == 'hide') {
$summary[] = $this
->t('Node image style: Hide');
}
else {
$summary[] = $this
->t('Node image style: Original image');
}
if (isset($image_styles[$this
->getSetting('photoswipe_node_style_first')])) {
$summary[] = $this
->t('Node image style of first image: @style', [
'@style' => $image_styles[$this
->getSetting('photoswipe_node_style_first')],
]);
}
elseif ($this
->getSetting('photoswipe_node_style_first') == 'hide') {
$summary[] = $this
->t('Node image style of first image: Hide');
}
else {
$summary[] = $this
->t('Node image style of first image: Original image');
}
if (isset($image_styles[$this
->getSetting('photoswipe_image_style')])) {
$summary[] = $this
->t('Photoswipe image style: @style', [
'@style' => $image_styles[$this
->getSetting('photoswipe_image_style')],
]);
}
else {
$summary[] = $this
->t('photoswipe image style: Original image');
}
if ($this
->getSetting('photoswipe_caption')) {
$caption_options = [
'alt' => $this
->t('Image Alt Tag'),
'title' => $this
->t('Image Title Tag'),
'node_title' => $this
->t('Node Title'),
];
if (array_key_exists($this
->getSetting('photoswipe_caption'), $caption_options)) {
$caption_setting = $caption_options[$this
->getSetting('photoswipe_caption')];
}
else {
$caption_setting = $this
->getSetting('photoswipe_caption');
}
$summary[] = $this
->t('Photoswipe Caption: @field', [
'@field' => $caption_setting,
]);
}
return $summary;
}