From 686197f61d2f3a9b3e230221a317d608572eac66 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 24 Dec 2019 20:06:05 +0100 Subject: [PATCH] Fall-back to the original version if no thumbnail is available --- wcfsetup/install/files/js/WCF.Attachment.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.Attachment.js b/wcfsetup/install/files/js/WCF.Attachment.js index 9c38650728..b6ac5d74bd 100644 --- a/wcfsetup/install/files/js/WCF.Attachment.js +++ b/wcfsetup/install/files/js/WCF.Attachment.js @@ -634,8 +634,22 @@ if (COMPILER_TARGET_DEFAULT) { * Inserts all attachments at once. */ _insertAll: function () { - var selector = (this._useThumbnail()) ? '.jsButtonAttachmentInsertThumbnail, .jsButtonAttachmentInsertPlain' : '.jsButtonAttachmentInsertFull, .jsButtonAttachmentInsertPlain'; - this._fileListSelector.children('li:not(.uploadFailed)').find(selector).trigger('click'); + var attachment, button, preferThumbnail = this._useThumbnail(); + for (var i = 0, length = this._fileListSelector[0].childNodes.length; i < length; i++) { + attachment = this._fileListSelector[0].childNodes[i]; + if (attachment.nodeName === 'LI' && !attachment.classList.contains('uploadFailed')) { + button = null; + if (preferThumbnail) { + button = elBySel('.jsButtonAttachmentInsertThumbnail, .jsButtonAttachmentInsertPlain', attachment); + } + + if (button === null) { + button = elBySel('.jsButtonAttachmentInsertFull, .jsButtonAttachmentInsertPlain', attachment); + } + + window.jQuery(button).trigger('click'); + } + } }, /** -- 2.20.1