Fixed support for disabled attachment thumbnails
authorAlexander Ebert <ebert@woltlab.com>
Sun, 18 Jun 2017 12:04:38 +0000 (14:04 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 18 Jun 2017 12:04:38 +0000 (14:04 +0200)
com.woltlab.wcf/templates/messageFormAttachments.tpl
wcfsetup/install/files/js/WCF.Attachment.js
wcfsetup/install/files/lib/data/attachment/Attachment.class.php

index f45ac57be8074fa572c7b10ac3329eeeb7ad2f6e..73a3000f0d4bd7606696e22f32853c106ddb0d0a 100644 (file)
@@ -1,5 +1,5 @@
 <div class="jsOnly formAttachmentContent messageTabMenuContent" id="attachments_{if $wysiwygSelector|isset}{$wysiwygSelector}{else}text{/if}">
-       <ul class="formAttachmentList clearfix"{if !$attachmentHandler->getAttachmentList()|count} style="display: none"{/if}>
+       <ul class="formAttachmentList clearfix"{if !$attachmentHandler->getAttachmentList()|count} style="display: none"{/if} data-enable-thumbnails="{if ATTACHMENT_ENABLE_THUMBNAILS}true{else}false{/if}">
                {foreach from=$attachmentHandler->getAttachmentList() item=$attachment}
                        <li class="box64" data-object-id="{@$attachment->attachmentID}" data-height="{@$attachment->height}" data-width="{@$attachment->width}" data-is-image="{@$attachment->isImage}">
                                {if $attachment->tinyThumbnailType}
index 9a6246860238ef23a2e63dc294e44691d0c27f2e..1381124a9b8974c7314c6bab7539d1c2dff3eebc 100644 (file)
@@ -318,6 +318,17 @@ WCF.Attachment.Upload = WCF.Upload.extend({
                return $li;
        },
        
+       /**
+        * Returns true if thumbnails are enabled and should be
+        * used instead of the original images.
+        * 
+        * @return      {boolean}
+        * @protected
+        */
+       _useThumbnail: function() {
+               return elDataBool(this._fileListSelector[0], 'enable-thumbnails');
+       },
+       
        /**
         * @see WCF.Upload._success()
         */
@@ -373,7 +384,7 @@ WCF.Attachment.Upload = WCF.Upload.extend({
                                $li.data('objectID', attachmentData.attachmentID);
                                
                                if (this._editorId) {
-                                       if (attachmentData.tinyURL) {
+                                       if (attachmentData.tinyURL || (!this._useThumbnail() && attachmentData.isImage)) {
                                                if (attachmentData.thumbnailURL) {
                                                        var $insertThumbnail = $('<li><span class="button small jsButtonAttachmentInsertThumbnail" data-object-id="' + attachmentData.attachmentID + '" data-url="' + WCF.String.escapeHTML(attachmentData.thumbnailURL) + '">' + WCF.Language.get('wcf.attachment.insertThumbnail') + '</span></li>').appendTo($buttonList);
                                                        $insertThumbnail.children('span.button').click($.proxy(this._insert, this));
@@ -461,7 +472,8 @@ WCF.Attachment.Upload = WCF.Upload.extend({
         * Inserts all attachments at once.
         */
        _insertAll: function() {
-               this._fileListSelector.children('li:not(.uploadFailed)').find('.jsButtonAttachmentInsertThumbnail, .jsButtonAttachmentInsertPlain').trigger('click');
+               var selector = (this._useThumbnail()) ? '.jsButtonAttachmentInsertThumbnail, .jsButtonAttachmentInsertPlain' : '.jsButtonAttachmentInsertFull, .jsButtonAttachmentInsertPlain';
+               this._fileListSelector.children('li:not(.uploadFailed)').find(selector).trigger('click');
        },
        
        /**
index b4b3e231f4f6d389412809f32b413da1e8006ba6..e3a0f0da4a064db1af1e28706ebfbef60a61ed5c 100644 (file)
@@ -191,7 +191,7 @@ class Attachment extends DatabaseObject implements IRouteController, IThumbnailF
         */
        public function showAsImage() {
                if ($this->isImage) {
-                       if (!$this->hasThumbnail() && ($this->width > ATTACHMENT_THUMBNAIL_WIDTH || $this->height > ATTACHMENT_THUMBNAIL_HEIGHT)) return false;
+                       if (ATTACHMENT_ENABLE_THUMBNAILS && !$this->hasThumbnail() && ($this->width > ATTACHMENT_THUMBNAIL_WIDTH || $this->height > ATTACHMENT_THUMBNAIL_HEIGHT)) return false;
                        
                        if ($this->canDownload()) return true;