Compare commits
2 Commits
546fde4d7a
...
16c745ce4c
Author | SHA1 | Date |
---|---|---|
buttle | 16c745ce4c | |
buttle | 7bb9c659ff |
|
@ -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,
|
||||||
|
|
|
@ -6,21 +6,16 @@ $this->headLink()->appendStylesheet($this->assetUrl('css/style.css',
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<!--
|
<style>
|
||||||
<script>
|
.sg_src_link {
|
||||||
console.log(<?= json_encode($images, JSON_UNESCAPED_SLASHES) ?>)
|
font-size: 0.70em;
|
||||||
</script>
|
}
|
||||||
-->
|
</style>
|
||||||
|
|
||||||
<?php $image_id = 0; ?>
|
<?php $image_id = 0; ?>
|
||||||
|
|
||||||
<div class="archive-item-block smart-gallery">
|
<div id="<?= $gallery_id ?>_wrap"
|
||||||
|
class="archive-item-block smart-gallery">
|
||||||
<?php if ($renderSourceLink) { ?>
|
|
||||||
<div class="source-link">
|
|
||||||
<a href="<?= $item_url ?>">Source</a>
|
|
||||||
</div>
|
|
||||||
<?php } ?>
|
|
||||||
|
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
<div class="masonry">
|
<div class="masonry">
|
||||||
|
@ -59,16 +54,20 @@ echo $this->inlineScript()
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
jQuery(document).ready(function() {
|
jQuery(document).ready(function() {
|
||||||
$(function(){
|
|
||||||
$(".<?= $gallery_id ?>").SmartPhoto({
|
$(".<?= $gallery_id ?>").SmartPhoto({
|
||||||
resizeStyle: 'fit',
|
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>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue