Skip to content

Commit

Permalink
Merge pull request #10 from SubOptimal/video_link
Browse files Browse the repository at this point in the history
Add support for displaying video attachments.
  • Loading branch information
rstockm authored Nov 11, 2023
2 parents 2e5ecc5 + c1c3a0b commit 6a204f2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ const displayPost = function(post) {
<img src="${post.account.avatar}" class="avatar-img rounded-circle mr-2">
<p class="m-0">${DOMPurify.sanitize(post.account.display_name)}</p>
</div>
${post.media_attachments[0] ? `<img src="${post.media_attachments[0].url}" class="card-img-top mb-2">` : ''}
${post.media_attachments[0] ?
(post.media_attachments[0].url.endsWith('.mp4') ?
`<video src="${post.media_attachments[0].url}" controls autoplay muted loop></video>` :
`<img src="${post.media_attachments[0].url}" class="card-img-top mb-2">`) :
''}
<p class="card-text">${DOMPurify.sanitize(post.content)}</p>
${post.spoiler_text ? `<p class="card-text text-muted spoiler">${DOMPurify.sanitize(post.spoiler_text)}</p>` : ''}
<p class="card-text text-right"><small class="text-muted"><a href="${post.url}" target="_blank" data-time="${post.created_at}">${timeAgo(secondsAgo(new Date(post.created_at)))}</a></small></p>
Expand Down

0 comments on commit 6a204f2

Please sign in to comment.