From 909513f73eb120ec1f6959d550539cf872b350e4 Mon Sep 17 00:00:00 2001 From: spitkov Date: Mon, 23 Sep 2024 18:00:18 -0400 Subject: [PATCH] image fix --- templates/base.html | 59 +++++++++++++++++++++++++++++++++++-- templates/group_detail.html | 25 +++++++++++++++- templates/index.html | 32 ++++++++++---------- templates/post_detail.html | 24 ++++++++++++++- 4 files changed, 121 insertions(+), 19 deletions(-) diff --git a/templates/base.html b/templates/base.html index 41928e4..da5df9f 100644 --- a/templates/base.html +++ b/templates/base.html @@ -68,7 +68,27 @@ background-color: inherit; } - {% block styles %}{% endblock %} + {% block styles %} + + {% endblock %}
@@ -148,8 +168,43 @@
+ + + - {% block scripts %}{% endblock %} + {% block scripts %} + + {% endblock %} \ No newline at end of file diff --git a/templates/group_detail.html b/templates/group_detail.html index 9998cca..6d46e10 100644 --- a/templates/group_detail.html +++ b/templates/group_detail.html @@ -95,7 +95,7 @@

{{ post.content|safe }}

{% if post.image_url %} - Post image + Post image {% endif %}
@@ -506,6 +506,29 @@ document.addEventListener('DOMContentLoaded', function() { } this.submit(); }); + + // Image modal functionality + const imageModal = document.getElementById('imageModal'); + const modalImage = document.getElementById('modalImage'); + const zoomInButton = document.getElementById('zoomInButton'); + const zoomOutButton = document.getElementById('zoomOutButton'); + const downloadButton = document.getElementById('downloadButton'); + + document.querySelectorAll('.post-image').forEach(img => { + img.addEventListener('click', function() { + modalImage.src = this.dataset.imageUrl; + downloadButton.href = this.dataset.imageUrl; + new bootstrap.Modal(imageModal).show(); + }); + }); + + zoomInButton.addEventListener('click', function() { + modalImage.style.transform = 'scale(1.2)'; + }); + + zoomOutButton.addEventListener('click', function() { + modalImage.style.transform = 'scale(1)'; + }); }); {% endblock %} \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 30436d6..ed0c266 100644 --- a/templates/index.html +++ b/templates/index.html @@ -40,9 +40,11 @@ {{ post.timestamp.strftime('%Y-%m-%d %H:%M:%S') }}

{{ post.content|safe }}

- {% if post.image_url %} - Post image - {% endif %} +
+ {% if post.image_url %} + Post image + {% endif %} +

{{ post.content|safe }}

{% if post.image_url %} - Post image + Post image {% endif %}
@@ -69,6 +69,28 @@
{% endblock %} +{% block modals %} + +{% endblock %} + {% block scripts %} {{ super() }}