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();
$mediaRenderer = $media->renderer();
if (strpos($mediaType, 'image/') !== false) {
$new_url = $media->originalUrl();
// original files size may be very large. /large/<name>.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,