Add support for displaying video attachments based on https://github.com/rstockm/mastowall/pull/10
This commit is contained in:
parent
1faf17e67f
commit
aacb05aee2
1 changed files with 11 additions and 2 deletions
13
script.js
13
script.js
|
@ -125,7 +125,11 @@ const displayPost = function(post) {
|
|||
<img src="${post.account.avatar}" class="avatar-img rounded-circle mr-2">
|
||||
<p class="m-0">${replaceEmojies(DOMPurify.sanitize(post.account.display_name), post.account.emojis)} <span class="user-name">@${DOMPurify.sanitize(post.account.acct)}</span></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">${replaceEmojies(DOMPurify.sanitize(post.content), post.emojis)}</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 class="time" href="${post.url}" target="_blank" data-time="${post.created_at}">${timeAgo(secondsAgo(new Date(post.created_at)))}</a></small></p>
|
||||
|
@ -203,7 +207,12 @@ const updateCarousel = function(slides, posts) {
|
|||
<hr>
|
||||
<div class="row align-items-center vertical-align-center">
|
||||
<div class="${post.media_attachments[0] ? `col-md-6` : `col-md-12`}"><div class="card-text" ${strip(postContent).length > 700 ? `style="font-size: ${strip(postContent).length > 1000 ? `0.5`:`0.9`}em;"`: ``}>${postContent}</div></div>
|
||||
${post.media_attachments[0] ? `<div class="col-md-6"><img src="${post.media_attachments[0].url}" class="card-img-bottom" align="center"> </div>` : ''}
|
||||
${post.media_attachments[0] ?
|
||||
(post.media_attachments[0].url.endsWith('.mp4') ?
|
||||
`<div class="col-md-6"><video src="${post.media_attachments[0].url}" controls autoplay muted loop class="card-img-bottom" align="center"></video></div>` :
|
||||
`<div class="col-md-6"><img src="${post.media_attachments[0].url}" class="card-img-bottom" align="center"> </div>`) :
|
||||
''}
|
||||
|
||||
</div>
|
||||
<hr>
|
||||
<p class="card-text text-right">
|
||||
|
|
Loading…
Reference in a new issue