Add video support with unified media display.
All checks were successful
Docker / build (release) Successful in 9s

This commit is contained in:
krek0 2026-05-16 15:13:14 +02:00
parent a634cc88bd
commit f4052a3d99
16 changed files with 700 additions and 224 deletions

View file

@ -12,6 +12,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<link rel="stylesheet" href="{% static 'lightgallery/css/lightgallery.css' %}" />
<link rel="stylesheet" href="{% static 'lightgallery/css/lg-zoom.css' %}" />
<link rel="stylesheet" href="{% static 'lightgallery/css/lg-thumbnail.css' %}" />
<link rel="stylesheet" href="{% static 'lightgallery/css/lg-video.css' %}" />
{% endblock %}
{% block extrajs %}
@ -25,6 +26,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
<script src="{% static 'lightgallery/plugins/hash/lg-hash.min.js' %}"></script>
<script src="{% static 'lightgallery/plugins/thumbnail/lg-thumbnail.min.js' %}"></script>
<script src="{% static 'lightgallery/plugins/zoom/lg-zoom.min.js' %}"></script>
<script src="{% static 'lightgallery/plugins/video/lg-video.min.js' %}"></script>
<script src="{% static 'gallery_justified.js' %}"></script>
<script src="{% static 'gallery_detail.js' %}"></script>
<script src="{% static 'sweetalert.js' %}"></script>
@ -90,12 +92,33 @@ SPDX-License-Identifier: GPL-3.0-or-later
</ul>
</div>
<div class="card-body p-0" id="lightgallery">
{% for photo in photos %}
<a class="photo-item" href="{{ photo.get_absolute_url }}" data-src="{{ photo.get_display_url }}" data-download-url="{{ photo.image.url }}" data-slide-name="{{ photo.id }}" data-owner-id="{{ photo.owner.id }}" data-is-public="{{ photo.is_public|yesno:'true,false' }}" data-width="{{ photo.image_width|default:1 }}" data-height="{{ photo.image_height|default:1 }}">
<img src="{{ photo.get_thumbnail_url }}" data-lazy="{{ photo.get_thumbnail_url }}" class="{% if not photo.is_public %}photo-private{% endif %}" alt="{{ photo.title }}{% if photo.date_taken %} - {{ photo.date_taken|date }} {{ photo.date_taken|time }}{% endif %}{% if photo.owner.get_full_name %} - {{ photo.owner.get_full_name }}{% else %} - {{ photo.owner.username }}{% endif %}{% if photo.license %} - {{ photo.license }}{% endif %}{% if not photo.is_public %} - !PRIVATE!{% endif %}">
{% for item in media_items %}
<a class="photo-item"
href="{% if not item.is_video %}{{ item.get_absolute_url }}{% endif %}"
{% if item.is_video %}
{% if item.get_thumbnail_url %}data-poster="{{ item.get_thumbnail_url }}"{% endif %}
data-video='{"source": [{"src": "{{ item.get_display_url }}", "type": "{{ item.get_mime_type }}"}], "attributes": {"controls": true, "preload": "metadata", "loop": true}}'
{% if item.thumbnail_width and item.thumbnail_height %}data-lg-size="{{ item.thumbnail_width }}-{{ item.thumbnail_height }}"{% endif %}
{% else %}
data-src="{{ item.get_display_url }}"
{% endif %}
data-download-url="{{ item.get_download_url }}"
data-slide-name="{{ item.id }}"
data-owner-id="{{ item.owner.id }}"
data-is-public="{{ item.is_public|yesno:'true,false' }}"
data-delete-url="{% url 'photologue:pl-media-delete' item.model_name item.id %}"
data-admin-url="{{ item.get_admin_url }}"
data-report-url="{% url 'photologue:pl-media-report' item.model_name item.id %}"
data-uncensor-url="{% url 'photologue:pl-media-uncensor' item.model_name item.id %}"
data-width="{{ item.thumbnail_width|default:1 }}"
data-height="{{ item.thumbnail_height|default:1 }}">
<img src="{{ item.get_thumbnail_url }}" data-lazy="{{ item.get_thumbnail_url }}"
class="{% if not item.is_public %}photo-private{% endif %}"
alt="{{ item.title }}{% if not item.is_video and item.date_taken %} - {{ item.date_taken|date }} {{ item.date_taken|time }}{% endif %}{% if item.owner.get_full_name %} - {{ item.owner.get_full_name }}{% else %} - {{ item.owner.username }}{% endif %}{% if not item.is_video and item.license %} - {{ item.license }}{% endif %}{% if not item.is_public %} - !PRIVATE!{% endif %}">
</a>
{% endfor %}
</div>
<div class="card-footer">
<a href="{% url 'photologue:pl-gallery-download' gallery.slug %}" class="btn btn-secondary btn-sm">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-download" viewBox="0 0 16 16">

View file

@ -0,0 +1,26 @@
{% extends "base.html" %}
{% comment %}
This file is part of photo21
Copyright (C) 2022 Amicale des élèves de l'ENS Paris-Saclay
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n %}
{% block title %}{% trans "Delete confirmation" %}{% endblock %}
{% block content %}
<div class="row">
<div class="col-lg-12">
<h1>{% trans "Delete confirmation" %}</h1>
<form method="post">{% csrf_token %}
<p>
{% blocktrans trimmed %}
Are you sure you want to delete <code>{{ object }}</code>?
{% endblocktrans %}
</p>
{{ form }}
<input type="submit" class="btn btn-danger" value="{% trans "Confirm" %}">
</form>
</div>
</div>
{% endblock %}