From 56cd480231f587fa757ae19c6640311df3f1c0ad Mon Sep 17 00:00:00 2001 From: buttle Date: Sat, 10 Jul 2021 21:11:41 +0200 Subject: [PATCH] enables more than one image attachment --- README.md | 4 +-- asset/css/gallery.css | 1 + src/Site/BlockLayout/ImageGallery.php | 34 +++++++++++++++++--- view/common/block-layout/imageGallery.phtml | 35 +++++++++++++++------ 4 files changed, 58 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index d60fca9..a5501bd 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ ``` cd ./modules -https://git.hangar.org/arcHIVE-tech/ImageGallery-omeka-module +wget https://git.hangar.org/arcHIVE-tech/ImageGallery-omeka-module/archive/main.zip unzip main.zip -mv ImageGallery-omeka-module/ ImageGallery +mv imagegallery-omeka-module/ ImageGallery rm main.zip ``` diff --git a/asset/css/gallery.css b/asset/css/gallery.css index fa6ef8d..e2135b1 100644 --- a/asset/css/gallery.css +++ b/asset/css/gallery.css @@ -46,6 +46,7 @@ } .archive-gallery .gallery__selector:checked + .gallery__img { opacity: 1; + height: 200px; } .archive-gallery .gallery__selector:checked ~ .gallery__thumb > img { box-shadow: 0 0 0 3px #0be2f6; diff --git a/src/Site/BlockLayout/ImageGallery.php b/src/Site/BlockLayout/ImageGallery.php index dc4c01d..0361523 100644 --- a/src/Site/BlockLayout/ImageGallery.php +++ b/src/Site/BlockLayout/ImageGallery.php @@ -70,22 +70,46 @@ class ImageGallery extends AbstractBlockLayout return ''; } - $thumbnails = []; - static $id = 0; + //$thumbnails = []; + static $gallery_id = 0; + $images = []; + /* $media = $attachments[0]->item()->media()[0]; $item = $attachments[0]->item(); $item_url = null; if ($block->dataValue('renderSourceLink')) { $item_url = $attachments[0]->item()->url(); } + */ + + foreach ($attachments as $attachment) + { + $img_id = 0; + foreach($attachment->item()->media() as $media) + { + $mediaType = $media->mediaType(); + $mediaRenderer = $media->renderer(); + if ((strpos($mediaType, 'image/') !== false) || (strpos($mediaRenderer, 'youtube') !== false)) { + array_push($images, ["media_url" => $media->originalUrl(), + "item_url" => $attachment->item()->url(), + "img_id" => 'gi_' . $gallery_id . '_' . $img_id, + ]); + $img_id = $img_id +1; + } + } + } + + + $max_width = $block->dataValue('width'); return $view->partial('common/block-layout/imageGallery', [ - 'gallery_id' => 'ig-' . ++$id, + 'gallery_id' => 'ig_' . ++$gallery_id, 'title' => $block->dataValue('title'), //'item' => $item, - 'images' => $item->media(), - 'item_url' => $item_url, + 'images' => $images, + //'images' => $item->media(), + //'item_url' => $item_url, //'renderSourceLink' => $block->dataValue('renderSourceLink'), 'width' => $block->dataValue('width'), 'max_width' => $max_width, diff --git a/view/common/block-layout/imageGallery.phtml b/view/common/block-layout/imageGallery.phtml index 43c4221..1097fdb 100644 --- a/view/common/block-layout/imageGallery.phtml +++ b/view/common/block-layout/imageGallery.phtml @@ -7,11 +7,9 @@ $this->headLink()->appendStylesheet($this->assetUrl('css/gallery.css', 'ImageGal @@ -52,6 +52,23 @@ $this->headLink()->appendStylesheet($this->assetUrl('css/gallery.css', 'ImageGal