adds source link to each image

This commit is contained in:
buttle 2021-10-14 14:20:51 +02:00
parent 7bb9c659ff
commit 16c745ce4c
1 changed files with 21 additions and 22 deletions

View File

@ -6,21 +6,16 @@ $this->headLink()->appendStylesheet($this->assetUrl('css/style.css',
?>
<!--
<script>
console.log(<?= json_encode($images, JSON_UNESCAPED_SLASHES) ?>)
</script>
-->
<style>
.sg_src_link {
font-size: 0.70em;
}
</style>
<?php $image_id = 0; ?>
<div class="archive-item-block smart-gallery">
<?php if ($renderSourceLink) { ?>
<div class="source-link">
<a href="<?= $item_url ?>">Source</a>
</div>
<?php } ?>
<div id="<?= $gallery_id ?>_wrap"
class="archive-item-block smart-gallery">
<div class="wrapper">
<div class="masonry">
@ -59,16 +54,20 @@ echo $this->inlineScript()
<script>
jQuery(document).ready(function() {
$(function(){
$(".<?= $gallery_id ?>").SmartPhoto({
resizeStyle: 'fit',
});
});
<?php if ($renderSourceLink) { ?>
var images_<?= $gallery_id ?> = <?= json_encode($images, JSON_UNESCAPED_SLASHES) ?>;
for (let i in images_<?= $gallery_id ?>) {
var image = images_<?= $gallery_id ?>[i]
var src_link = '<div class="sg_src_link"><a href="'+image['item_url']+'">Source</a></div>';
var gallery_image = $('#<?= $gallery_id ?>_wrap').find('img[src="'+image['media_url']+'"]')
if ( !($(gallery_image).next().attr('src') == image['media_url']) ){
$(gallery_image).closest('.brick').append(src_link)
console.log(image['media_url'])
}
}
<?php } ?>
});
function updateSourceURL(thumbnail){
$(thumbnail).closest(".archive-gallery")
.find('.source-link')
.find('a').prop('href', $(thumbnail).attr('item_url'));
}
</script>