improves function to fetch large media

This commit is contained in:
buttle 2021-10-14 13:34:25 +02:00
parent 546fde4d7a
commit 7bb9c659ff
1 changed files with 7 additions and 5 deletions

View File

@ -91,11 +91,13 @@ class SmartGallery extends AbstractBlockLayout
$mediaType = $media->mediaType(); $mediaType = $media->mediaType();
$mediaRenderer = $media->renderer(); $mediaRenderer = $media->renderer();
if (strpos($mediaType, 'image/') !== false) { if (strpos($mediaType, 'image/') !== false) {
$new_url = $media->originalUrl(); $thumbs = $media->thumbnailUrls();
// original files size may be very large. /large/<name>.jpg is smaller if (isset($thumbs['large'])) {
$new_url = substr_replace($new_url, 'jpg', strrpos($new_url, '.') +1); $media_url = $thumbs['large'];
$new_url = str_replace("original", "large", $new_url); } else {
array_push($images, ["media_url" => $new_url, $media_url = $media->originalUrl();
}
array_push($images, ["media_url" => $media_url,
"item_url" => $attachment->item()->url(), "item_url" => $attachment->item()->url(),
"image_title" => $media->title(), "image_title" => $media->title(),
"img_id" => 'gi_' . $gallery_id . '_' . $img_id, "img_id" => 'gi_' . $gallery_id . '_' . $img_id,