Fall-back to the original version if no thumbnail is available
authorAlexander Ebert <ebert@woltlab.com>
Tue, 24 Dec 2019 19:06:05 +0000 (20:06 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 24 Dec 2019 19:06:05 +0000 (20:06 +0100)
wcfsetup/install/files/js/WCF.Attachment.js

index 9c386507282aaafc292a695d8af6a747e88aedc1..b6ac5d74bd9c61b851ad6a0517757f7c51e2799d 100644 (file)
@@ -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');
+                               }
+                       }
                },
                
                /**