From 7bb9c659ff647e3cb13c3d3a540ed47056d1efa1 Mon Sep 17 00:00:00 2001 From: buttle Date: Thu, 14 Oct 2021 13:34:25 +0200 Subject: [PATCH] improves function to fetch large media --- src/Site/BlockLayout/SmartGallery.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Site/BlockLayout/SmartGallery.php b/src/Site/BlockLayout/SmartGallery.php index 61d47b7..9604898 100644 --- a/src/Site/BlockLayout/SmartGallery.php +++ b/src/Site/BlockLayout/SmartGallery.php @@ -91,11 +91,13 @@ class SmartGallery extends AbstractBlockLayout $mediaType = $media->mediaType(); $mediaRenderer = $media->renderer(); if (strpos($mediaType, 'image/') !== false) { - $new_url = $media->originalUrl(); - // original files size may be very large. /large/.jpg is smaller - $new_url = substr_replace($new_url, 'jpg', strrpos($new_url, '.') +1); - $new_url = str_replace("original", "large", $new_url); - array_push($images, ["media_url" => $new_url, + $thumbs = $media->thumbnailUrls(); + if (isset($thumbs['large'])) { + $media_url = $thumbs['large']; + } else { + $media_url = $media->originalUrl(); + } + array_push($images, ["media_url" => $media_url, "item_url" => $attachment->item()->url(), "image_title" => $media->title(), "img_id" => 'gi_' . $gallery_id . '_' . $img_id,