Add 'loop' attribute for videos in 'gifs' communities

This commit is contained in:
freamon 2024-05-12 10:31:04 +01:00
parent ade07d2658
commit bd7df400aa
2 changed files with 5 additions and 2 deletions

View file

@ -545,6 +545,9 @@ class Community(db.Model):
return True
return False
def loop_videos(self) -> bool:
return 'gifs' in self.name
def delete_dependencies(self):
for post in self.posts:
post.delete_dependencies()

View file

@ -85,7 +85,7 @@
<p><audio controls preload="{{ 'none' if low_bandwidth else 'metadata' }}" src="{{ post.url }}"></audio></p>
{% elif post.url.endswith('.mp4') or post.url.endswith('.webm') %}
<p>
<video class="responsive-video" controls preload="{{ 'metadata' if low_bandwidth else 'auto' }}">
<video class="responsive-video" controls preload="{{ 'metadata' if low_bandwidth else 'auto' }}" {{ 'loop' if post.community.loop_videos() }}>
{% if post.url.endswith('.mp4') %}
<source src="{{ post.url }}" type="video/mp4" />
{% elif post.url.endswith('.webm') %}
@ -106,7 +106,7 @@
<span class="fe fe-external"></span></a></p>
{% if post.url.endswith('.mp4') or post.url.endswith('.webm') %}
<p>
<video class="responsive-video" controls preload="{{ 'none' if low_bandwidth else 'auto' }}" {{ 'autoplay muted' if autoplay }}>
<video class="responsive-video" controls preload="{{ 'none' if low_bandwidth else 'auto' }}" {{ 'autoplay muted' if autoplay }} {{ 'loop' if post.community.loop_videos() }}>
{% if post.url.endswith('.mp4') %}
<source src="{{ post.url }}" type="video/mp4" />
{% elif post.url.endswith('.webm') %}