Added image attachments to replies that have them
All checks were successful
/ weblog.lol (push) Successful in 13s
All checks were successful
/ weblog.lol (push) Successful in 13s
This commit is contained in:
parent
8cbce7744d
commit
9ad2ac4215
2 changed files with 19 additions and 2 deletions
|
@ -132,7 +132,22 @@ function renderReplies(status, replies, replyContainer, template) {
|
|||
article.querySelector('time.dt-published').datetime = reply.created_at
|
||||
article.querySelector('time.dt-published').innerText = luxon.DateTime.fromISO(reply.created_at).toRelative()
|
||||
|
||||
article.querySelector('.reply-content').innerHTML = reply.content
|
||||
const contentEl = article.querySelector('.reply-content')
|
||||
contentEl.innerHTML = reply.content
|
||||
// TODO: images
|
||||
if(reply.media_attachments && reply.media_attachments.length > 0)
|
||||
for(let att in reply.media_attachments.filter(a => a.type == "image")) {
|
||||
const attachment = reply.media_attachments[att];
|
||||
const imgLink = document.createElement('a')
|
||||
imgLink.href = attachment.remote_url
|
||||
imgLink.target = "_blank"
|
||||
const img = document.createElement('img')
|
||||
img.src = attachment.preview_url
|
||||
if(attachment.description) img.alt = img.title = attachment.description
|
||||
imgLink.appendChild(img)
|
||||
contentEl.appendChild(imgLink)
|
||||
}
|
||||
|
||||
|
||||
article.querySelector('a.source').href = reply.url
|
||||
article.querySelector('.application').innerText = reply.application.name
|
||||
|
|
|
@ -121,7 +121,9 @@ article p {
|
|||
width: 100%;
|
||||
}
|
||||
|
||||
article p:has(img) {
|
||||
article p:not(.reply-content):has(img),
|
||||
a:has(img) {
|
||||
display: block;
|
||||
text-align: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue