From 7cf611d197ba5d216ea5a05bb40137773e095f74 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Thu, 24 Oct 2024 00:39:10 +0900 Subject: [PATCH] Fix broken image when editing comment with non-image attachments (#32319) Fix #32316 --- web_src/js/features/dropzone.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web_src/js/features/dropzone.ts b/web_src/js/features/dropzone.ts index f652af0456..c9b0149df5 100644 --- a/web_src/js/features/dropzone.ts +++ b/web_src/js/features/dropzone.ts @@ -128,10 +128,12 @@ export async function initDropzone(dropzoneEl) { fileUuidDict = {}; for (const attachment of respData) { const file = {name: attachment.name, uuid: attachment.uuid, size: attachment.size}; - const imgSrc = `${attachmentBaseLinkUrl}/${file.uuid}`; dzInst.emit('addedfile', file); - dzInst.emit('thumbnail', file, imgSrc); dzInst.emit('complete', file); + if (isImageFile(file.name)) { + const imgSrc = `${attachmentBaseLinkUrl}/${file.uuid}`; + dzInst.emit('thumbnail', file, imgSrc); + } addCopyLink(file); // it is from server response, so no "type" fileUuidDict[file.uuid] = {submitted: true}; const input = createElementFromAttrs('input', {name: 'files', type: 'hidden', id: `dropzone-file-${file.uuid}`, value: file.uuid});