remotes/1693045480750635534/spooky-22
Aevann1 2021-12-28 16:52:57 +02:00
parent dfb9aa2cfd
commit 89150935b6
2 changed files with 12 additions and 4 deletions

View File

@ -218,6 +218,10 @@ class Submission(Base):
if domain.startswith("www."): domain = domain.split("www.")[1]
return domain.replace("old.reddit.com", "reddit.com")
@property
@lazy
def is_youtube(self):
return self.domain == "youtube.com" and self.embed_url and self.embed_url.startswith('<lite-youtube')
@property
@lazy
@ -225,7 +229,7 @@ class Submission(Base):
if self.over_18: return f"https://{site}/static/assets/images/nsfw.webp"
elif not self.url: return f"https://{site}/static/assets/images/{site_name}/default_text.webp"
elif self.thumburl: return self.thumburl
elif "youtu.be" in self.domain or "youtube.com" == self.domain or self.is_video: return f"https://{site}/static/assets/images/default_thumb_yt.webp"
elif self.is_youtube or self.is_video: return f"https://{site}/static/assets/images/default_thumb_yt.webp"
else: return f"https://{site}/static/assets/images/default_thumb_link.webp"
@property

View File

@ -137,7 +137,11 @@
<a href="javascript:void(0)" data-bs-toggle="modal" data-bs-target="#expandImageModal" data-bs-url="{{p.realurl(v)}}" onclick="expandDesktopImage('{{ p.realurl(v) }}')">
<img alt="post thumnail" loading="lazy" src="{{p.thumb_url}}" class="post-img">
</a>
{% elif (p.url and (p.url.lower().endswith('.mp4') or p.url.lower().endswith('.webm'))) or (p.embed_url and "youtu" in p.domain) or (p.url and "streamable.com/e/" in p.url) %}
{% elif p.is_video %}
<a href="javascript:void(0)" onclick="document.getElementById('video-{{p.id}}').classList.toggle('d-none');document.getElementById('video2-{{p.id}}').pause()">
<img alt="post thumnail" loading="lazy" src="{{p.thumb_url}}" class="post-img">
</a>
{% elif p.is_youtube %}
<a href="javascript:void(0)" onclick="document.getElementById('video-{{p.id}}').classList.toggle('d-none')">
<img alt="post thumnail" loading="lazy" src="{{p.thumb_url}}" class="post-img">
</a>
@ -512,11 +516,11 @@
</div>
{% elif p.is_video %}
<div id="video-{{p.id}}" style="text-align: center" class="{% if p.over_18 or not ((v and v.cardview) or (not v and environ.get('CARD_VIEW') == '1')) %}d-none{% endif %} mt-4">
<video controls preload="none" class="embedvid">
<video id="video2-{{p.id}}" controls preload="none" class="embedvid">
<source src="{{p.realurl(v)}}" type="video/mp4">
</video>
</div>
{% elif p.embed_url and p.domain in ['youtu.be','youtube.com'] and p.embed_url.startswith('<lite-youtube') %}
{% elif p.is_youtube %}
<div id="video-{{p.id}}" class="{% if p.over_18 or not ((v and v.cardview) or (not v and environ.get('CARD_VIEW') == '1')) %}d-none{% endif %} mt-3 mb-4">
{{p.embed_url | safe}}
</div>