make sure post has valid media

This commit is contained in:
teddit 2020-12-31 18:20:24 +01:00
parent eaa441de55
commit 7aad960d22
1 changed files with 38 additions and 37 deletions

View File

@ -103,44 +103,45 @@ html
a(href="" + post.images.source + "") a(href="" + post.images.source + "")
img(src="" + post.images.source + "", alt="") img(src="" + post.images.source + "", alt="")
else else
if post.media.not_hosted_in_reddit if post.media
if post.media.source === 'YouTube' if post.media.not_hosted_in_reddit
.video if post.media.source === 'YouTube'
.title
a(href="" + post.media.embed_src + "", target="_blank", rel="noopener noreferrer")
p #{cleanTitle(post.media.title)}
span(class="domain") (#{post.domain})
.video-holder
a(href="" + post.media.embed_src + "", target="_blank", rel="noopener noreferrer")
img(src="" + post.media.thumbnail + "")
div(class="youtube-info")
p YouTube video info:
p #{cleanTitle(post.media.title)} <a href="#{post.media.embed_src}">#{post.media.embed_src}</a>
p #{post.media.author_name} <a href="#{post.media.author_url}">#{post.media.author_url}</a>
else
if post.media.source === 'external'
if post.images
.image
a(href="" + post.media.embed_src + "", target="_blank", rel="noopener noreferrer")
img(src="" + post.images.source + "", alt="")
if !post.media.embed_src.startsWith("https://twitter.com")
p
| source:
a(href="" + post.media.embed_src + "", target="_blank", rel="noopener noreferrer")
p(class="source-url") #{post.media.embed_src}
else
.video .video
a(href="" + post.media.source + "") .title
img(src="" + post.media.source + "") a(href="" + post.media.embed_src + "", target="_blank", rel="noopener noreferrer")
p Embed URL: p #{cleanTitle(post.media.title)}
a(href="" + post.media.embed_src + "", target="_blank", rel="noopener noreferrer") span(class="domain") (#{post.domain})
p #{post.media.embed_src} .video-holder
else a(href="" + post.media.embed_src + "", target="_blank", rel="noopener noreferrer")
.video img(src="" + post.media.thumbnail + "")
video(controls="controls", autoplay="autoplay", loop="loop") div(class="youtube-info")
source(src="" + post.media.source + "", type="video/mp4") p YouTube video info:
| Your browser does not support the video element. p #{cleanTitle(post.media.title)} <a href="#{post.media.embed_src}">#{post.media.embed_src}</a>
a(href="" + post.media.source + "") [media] p #{post.media.author_name} <a href="#{post.media.author_url}">#{post.media.author_url}</a>
else
if post.media.source === 'external'
if post.images
.image
a(href="" + post.media.embed_src + "", target="_blank", rel="noopener noreferrer")
img(src="" + post.images.source + "", alt="")
if !post.media.embed_src.startsWith("https://twitter.com")
p
| source:
a(href="" + post.media.embed_src + "", target="_blank", rel="noopener noreferrer")
p(class="source-url") #{post.media.embed_src}
else
.video
a(href="" + post.media.source + "")
img(src="" + post.media.source + "")
p Embed URL:
a(href="" + post.media.embed_src + "", target="_blank", rel="noopener noreferrer")
p #{post.media.embed_src}
else
.video
video(controls="controls", autoplay="autoplay", loop="loop")
source(src="" + post.media.source + "", type="video/mp4")
| Your browser does not support the video element.
a(href="" + post.media.source + "") [media]
if post.selftext if post.selftext
div.usertext-body !{post.selftext} div.usertext-body !{post.selftext}
if post.contest_mode if post.contest_mode