Skip to content
Snippets Groups Projects
Commit 0636fded authored by Julian Pustkuchen's avatar Julian Pustkuchen
Browse files

Issue #2936119 by ChuckSimply, Anybody: Hide Additional Images (D8): Fatal Error

parent dd5baec9
No related branches found
Tags 7.x-2.0-beta1
No related merge requests found
......@@ -76,7 +76,7 @@ function template_preprocess_photoswipe_image_formatter(array &$variables)
}
// Render as a standard image if an image style is not given.
if (empty($image['#style_name'])) {
if (empty($image['#style_name']) || $image['#style_name'] === 'hide') {
$image['#theme'] = 'image';
}
......@@ -125,9 +125,11 @@ function template_preprocess_photoswipe_image_formatter(array &$variables)
$variables['image'] = $image;
$variables['path'] = $path;
$variables['attributes'] = [
'class' => 'photoswipe',
'data-size' => $dimensions['width'] . 'x' . $dimensions['height'],
'data-overlay-title' => $caption,
];
$variables['attributes']['class'][] = 'photoswipe';
$variables['attributes']['data-size'] = $dimensions['width'] . 'x' . $dimensions['height'];
$variables['attributes']['data-overlay-title'] = $caption;
if($image['#style_name'] === 'hide'){
// Do not display if hidden is selected:
$variables['attributes']['class'][] = 'hidden';
}
}
......@@ -67,9 +67,9 @@ class PhotoswipeFieldFormatter extends FormatterBase {
// Set our caption options.
$caption_options = [
'title' => $this->t('Image Title Tag'),
'alt' => $this->t('Image Alt Tag'),
'node_title' => $this->t('Node Title'),
'title' => $this->t('Image title tag'),
'alt' => $this->t('Image alt tag'),
'node_title' => $this->t('Entity title'),
];
// Add the other node fields as options.
if (!empty($form['#fields'])) {
......@@ -137,9 +137,9 @@ class PhotoswipeFieldFormatter extends FormatterBase {
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'),
'alt' => $this->t('Image alt tag'),
'title' => $this->t('Image title tag'),
'node_title' => $this->t('Entity title'),
];
if (array_key_exists($this->getSetting('photoswipe_caption'), $caption_options)) {
$caption_setting = $caption_options[$this->getSetting('photoswipe_caption')];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment