fix: always try to load file as image in info page

This commit is contained in:
Bobby 2022-06-28 13:02:38 +07:00
parent e55be5ee0a
commit 8cbdca4efc
No known key found for this signature in database
GPG Key ID: 941839794CBF5A09

View File

@ -167,16 +167,15 @@ page.loadFileinfo = () => {
page.downloadBtn.setAttribute('href', fileUrl)
page.clipboardBtn.dataset.clipboardText = fileUrl
const isimage = page.file.type.startsWith('image/')
const img = page.fileinfoContainer.querySelector('img')
img.setAttribute('alt', page.file.name || '')
img.src = `${page.uploadRoot}/${page.file.name}`
img.parentNode.classList.remove('is-hidden')
img.onerror = event => event.currentTarget.classList.add('is-hidden')
const isvideo = page.file.type.startsWith('video/')
const isaudio = page.file.type.startsWith('audio/')
if (isimage) {
const img = page.fileinfoContainer.querySelector('img')
img.setAttribute('alt', page.file.name || '')
img.src = `${page.uploadRoot}/${page.file.name}`
img.parentNode.classList.remove('is-hidden')
img.onerror = event => event.currentTarget.classList.add('is-hidden')
} else if (isvideo || isaudio) {
if (isvideo || isaudio) {
page.playerBtn.setAttribute('href', `../v/${page.file.name}`)
page.playerBtn.parentNode.parentNode.classList.remove('is-hidden')
}