enables more than one image attachment

This commit is contained in:
buttle 2021-07-10 21:11:41 +02:00
parent 7310d43c3c
commit 56cd480231
4 changed files with 58 additions and 16 deletions

View File

@ -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
```

View File

@ -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;

View File

@ -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,

View File

@ -7,11 +7,9 @@ $this->headLink()->appendStylesheet($this->assetUrl('css/gallery.css', 'ImageGal
<div class="archive-gallery">
<?php if ($item_url) { ?>
<div class="source-link">
<a href="<?= $item_url ?>">Source</a>
</div>
<?php } ?>
<div class="source-link">
<a href="<?= $item_url ?>">Source</a>
</div>
<section id="<?= $gallery_id ?>"
class="gallery"
@ -28,12 +26,14 @@ $this->headLink()->appendStylesheet($this->assetUrl('css/gallery.css', 'ImageGal
class="gallery__selector"/>
<img class="gallery__img"
style=""
src="<?= $image->primaryMedia()->originalUrl() ?>"
alt="<?= $image->primaryMedia()->source() ?>"
src="<?= $image['media_url'] ?>"
alt="<?= $image['media_url'] ?>"
/>
<label for="<?= $img_id ?>" class="gallery__thumb">
<img src="<?= $image->primaryMedia()->thumbnailUrl('large') ?>"
alt="Thumbnail: <?= $image->primaryMedia()->source() ?>"
<img src="<?= $image['media_url'] ?>"
alt="<?= $image['media_url'] ?>"
item_url="<?= $image['item_url'] ?>"
onclick="updateSourceURL(this)"
/>
</label>
</div>
@ -52,6 +52,23 @@ $this->headLink()->appendStylesheet($this->assetUrl('css/gallery.css', 'ImageGal
<script>
function updateSourceURL(thumbnail){
$(thumbnail).closest(".archive-gallery")
.find('.source-link')
.find('a').prop('href', $(thumbnail).attr('item_url'));
}
jQuery(document).ready(function() {
$('.archive-gallery').each(function(i, el){
var first_thumbnamil = $(el).find('.gallery__thumb:first')
.find('img');
updateSourceURL(first_thumbnamil)
});
});
jQuery(document).ready(function() {
var gallery_image_height=0;
$( ".gallery__img" ).each(function( index ) {