From e4ca2eecce316990e9af154c4f678c52bbcb79ce Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 31 Mar 2024 18:58:52 -0700 Subject: [PATCH] Support video elements in photogallery. --- photogallery.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/photogallery.py b/photogallery.py index 5a4f091..a802a43 100644 --- a/photogallery.py +++ b/photogallery.py @@ -109,7 +109,8 @@ article .photograph:last-of-type { margin-bottom: 0; } -.photograph img +.photograph img, +.photograph video { max-height: 92vh; border-radius: 8px; @@ -286,12 +287,19 @@ pre,

Click each photo to view its full resolution. Click the number to download it.

{% for file in files %} + {% if file.extension == 'jpg' %}
{% if with_download_links %} #{{loop.index}}/{{files|length}} {% endif %}
+ {% elif file.extension in ['mp4', 'mov'] %} +
+

{{file.replace_extension('').basename}}

+ +
+ {% endif %} {% endfor %} @@ -332,7 +340,7 @@ function get_center_img() { const element = document.elementFromPoint(center_x, center_y); console.log(element); - if (element.tagName === "IMG") + if (element.tagName === "IMG" || element.tagName === "VIDEO") { return element; } @@ -345,7 +353,7 @@ function get_center_img() } function next_img(img) { - const images = Array.from(document.images); + const images = Array.from(document.querySelectorAll("img,video")); const this_index = images.indexOf(img); if (this_index === images.length-1) { @@ -355,7 +363,7 @@ function next_img(img) } function previous_img(img) { - const images = Array.from(document.images); + const images = Array.from(document.querySelectorAll("img,video")); const this_index = images.indexOf(img); if (this_index === 0) {