Compare commits

...

2 commits

Author SHA1 Message Date
j
e48a1415a6 don't set hash onload 2025-04-27 11:46:42 +01:00
j
a6e76776cc download link for everyone 2025-04-27 11:34:12 +01:00
3 changed files with 16 additions and 8 deletions
camp/static/js
content/templates

View file

@ -217,7 +217,7 @@ function loadGallery(images, idx, main, thumbnails) {
}
})
function updateGallery(index) {
function updateGallery(index, init) {
mainImage.src = images[index].src.replace('_display', '_thumbnail');
setTimeout(() => {
mainImage.src = images[index].src;
@ -253,10 +253,12 @@ function loadGallery(images, idx, main, thumbnails) {
}
prevBtn.disabled = index === 0;
nextBtn.disabled = index === images.length - 1;
if (idx == 'inline') {
document.location.hash = `#${index + 1}`
} else {
document.location.hash = `#${idx + 1}/${index + 1}`
if (!init) {
if (idx == 'inline') {
document.location.hash = `#${index + 1}`
} else {
document.location.hash = `#${idx + 1}/${index + 1}`
}
}
}
@ -299,7 +301,7 @@ function loadGallery(images, idx, main, thumbnails) {
};
idx != 'inline' && createThumbnails();
updateGallery(currentIndex);
updateGallery(currentIndex, true);
const imagesIndex = images.map(img => img.src);
return {

View file

@ -5,7 +5,7 @@
<li><a href="{{ gallery.get_absolute_url }}#{{forloop.counter}}"><img src="{{ photo.get_thumbnail_url }}"
class="photo"
data-caption="{{ photo.caption_html }}"
{% if request.user.is_staff %}data-orig="{{ photo.image.url }}"{% endif %}
data-orig="{{ photo.image.url }}"
{% if request.user.is_staff %}data-edit="{{ photo.edit_url }}"{% endif %}
></a></li>
{% endfor %}

View file

@ -33,7 +33,13 @@
{% for photo in gallery.public %}
<div style="float: left; padding: 4px">
<a href="{{ gallery.get_absolute_url }}#{{forloop.counter}}">
<img src="{{ photo.get_thumbnail_url }}" class="thumbnail photo" alt="{{ photo.title }}" data-caption="{{ photo.caption_html }}"{% if request.user.is_staff %} data-orig="{{ photo.image.url }}"{% endif %}>
<img
src="{{ photo.get_thumbnail_url }}"
class="thumbnail photo"
alt="{{ photo.title }}"
data-caption="{{ photo.caption_html }}"
data-orig="{{ photo.image.url }}"
>
</a>
</div>
{% endfor %}