From c639855a33b3e4b01362ddaf862bf5d2c6b62d01 Mon Sep 17 00:00:00 2001 From: halftrainedharry Date: Wed, 2 Jul 2025 17:07:53 +0200 Subject: [PATCH] Fix thumbnails in mediasource --- .../model/gallery/galleryalbumsmediasource.class.php | 9 +++++++++ .../gallery/src/Model/GalleryAlbumsMediaSource.php | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/core/components/gallery/model/gallery/galleryalbumsmediasource.class.php b/core/components/gallery/model/gallery/galleryalbumsmediasource.class.php index 25c00b4..912b1df 100644 --- a/core/components/gallery/model/gallery/galleryalbumsmediasource.class.php +++ b/core/components/gallery/model/gallery/galleryalbumsmediasource.class.php @@ -180,6 +180,15 @@ public function getObjectsInContainer($path) { 'fullRelativeUrl' => $itemArray['relativeImage'], ); } + + $modx_version = $this->xpdo->getVersionData(); + if (version_compare($modx_version['full_version'], '2.8.0-pl') >= 0) { + // For MODX versions newer or equal to 2.8.0, undo any ampersand encoding (as it will be done in JS) + $list = array_map(function($item) { + $item['thumb'] = str_replace('&', '&', $item['thumb']); + return $item; + }, $list); + } } return $list; } diff --git a/core/components/gallery/src/Model/GalleryAlbumsMediaSource.php b/core/components/gallery/src/Model/GalleryAlbumsMediaSource.php index 65d9184..d9b3454 100644 --- a/core/components/gallery/src/Model/GalleryAlbumsMediaSource.php +++ b/core/components/gallery/src/Model/GalleryAlbumsMediaSource.php @@ -187,12 +187,13 @@ public function getObjectsInContainer($path) { 'image' => $item->get('image'), 'image_width' => $imageWidth, 'image_height' => $imageHeight, - 'thumb' => $item->get('thumbnail'), + 'thumb' => str_replace('&', '&', $item->get('thumbnail')), 'thumb_width' => $thumbWidth, 'thumb_height' => $thumbHeight, 'url' => $itemArray['image'], 'relativeUrl' => $itemArray['relativeImage'], 'fullRelativeUrl' => $itemArray['relativeImage'], + 'preview' => 1 ); } }