public function ImageShadowboxFormatter::settingsSummary in Shadowbox 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
- image_shadowbox/
lib/ Drupal/ image_shadowbox/ Plugin/ Field/ FieldFormatter/ ImageShadowboxFormatter.php, line 99 - Contains \Drupal\image_shadowbox\Plugin\field\formatter\ImageShadowboxFormatter.
Class
- ImageShadowboxFormatter
- Plugin implementation of the 'image_shadowbox' formatter.
Namespace
Drupal\image_shadowbox\Plugin\Field\FieldFormatterCode
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_setting = $this
->getSetting('image_style');
if (isset($image_styles[$image_style_setting])) {
$summary[] = t('Image style: @style', array(
'@style' => $image_styles[$image_style_setting],
));
}
else {
$summary[] = t('Original image');
}
if (isset($image_styles[$this
->getSetting('image_link')])) {
$summary[] = t('Linked to: @style', array(
'@style' => $image_styles[$this
->getSetting('image_link')],
));
}
else {
$summary[] = t('Linked to: Original image');
}
$gallery_options = array(
'page' => 'gallery page',
'field' => 'gallery field page',
'nid' => 'gallery entity',
'field_nid' => 'gallery field entity',
);
if (isset($gallery_options[$this
->getSetting('gallery')])) {
$summary[] = t('as @gallery', array(
'@gallery' => ($this
->getSetting('compact') ? 'compact ' : '') . $gallery_options[$this
->getSetting('gallery')],
));
}
$title_options = array(
'title' => 'image title',
'alt' => 'image alt',
'node' => 'node title',
);
if (isset($title_options[$this
->getSetting('title')])) {
$summary[] = t('with @title as caption', array(
'@title' => $title_options[$this
->getSetting('title')],
));
}
return $summary;
}