Fix small media image previews directly after upload
authorMatthias Schmidt <gravatronics@live.com>
Sat, 17 Aug 2019 11:58:02 +0000 (13:58 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 17 Aug 2019 11:58:02 +0000 (13:58 +0200)
See #2576
See #3035

wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Media/List.js
wcfsetup/install/files/js/WoltLabSuite/Core/Media/Upload.js
wcfsetup/install/files/lib/data/media/MediaAction.class.php

index 1d1a8c889383bfea378585261dd122a2ca2ac3ca..b7a2045bbb26e3fd334a803560d9b44a0a3ff144 100644 (file)
@@ -49,7 +49,8 @@ define([
                        options = options || {};
                        _upload = new MediaListUpload('uploadButton', 'mediaListTableBody', {
                                categoryId: options.categoryId,
-                               multiple: true
+                               multiple: true,
+                               elementTagSize: 48
                        });
                        
                        MediaClipboard.init(
index 1c97c2201c8619e18f00d57cf8a9fb1b37ca7db3..3dd1faa5ca31e8d76d9dbbe6a8907e6af3d3cd25 100644 (file)
@@ -60,6 +60,11 @@ define(
        function MediaUpload(buttonContainerId, targetId, options) {
                options = options || {};
                
+               this._elementTagSize = 144;
+               if (options.elementTagSize) {
+                       this._elementTagSize = options.elementTagSize;
+               }
+               
                this._mediaManager = null;
                if (options.mediaManager) {
                        this._mediaManager = options.mediaManager;
@@ -194,20 +199,19 @@ define(
                 * @see WoltLabSuite/Core/Upload#_getParameters
                 */
                _getParameters: function() {
+                       var parameters = {
+                               elementTagSize: this._elementTagSize
+                       };
                        if (this._mediaManager) {
-                               var parameters = {
-                                       imagesOnly: this._mediaManager.getOption('imagesOnly')
-                               };
+                               parameters.imagesOnly = this._mediaManager.getOption('imagesOnly');
                                
                                var categoryId = this._mediaManager.getCategoryId();
                                if (categoryId) {
                                        parameters.categoryID = categoryId;
                                }
-                               
-                               return Core.extend(MediaUpload._super.prototype._getParameters.call(this), parameters);
                        }
                        
-                       return MediaUpload._super.prototype._getParameters.call(this);
+                       return Core.extend(MediaUpload._super.prototype._getParameters.call(this), parameters);
                },
                
                /**
@@ -218,7 +222,10 @@ define(
                 * @param       {integer}       size            size of the file icon in pixels
                 */
                _replaceFileIcon: function(fileIcon, media, size) {
-                       if (media.tinyThumbnailType) {
+                       if (media.elementTag) {
+                               fileIcon.parentElement.innerHTML = media.elementTag;
+                       }
+                       else if (media.tinyThumbnailType) {
                                var img = elCreate('img');
                                elAttr(img, 'src', media.tinyThumbnailLink);
                                elAttr(img, 'alt', '');
index 40c06243bddbdaffd23c8395c25bc966682bafc1..7cc233e20b1b35df626aa0bfceccdb4c4c31bc84 100644 (file)
@@ -93,7 +93,7 @@ class MediaAction extends AbstractDatabaseObjectAction implements ISearchAction,
                        }
                        
                        // fetch media objects from database
-                       $mediaList = new MediaList();
+                       $mediaList = new ViewableMediaList();
                        $mediaList->setObjectIDs($mediaIDs);
                        $mediaList->readObjects();
                        
@@ -147,6 +147,7 @@ class MediaAction extends AbstractDatabaseObjectAction implements ISearchAction,
                        'caption' => $media instanceof ViewableMedia ? $media->caption : [],
                        'captionEnableHtml' => $media->captionEnableHtml,
                        'categoryID' => $media->categoryID,
+                       'elementTag' => $media instanceof ViewableMedia ? $media->getElementTag($this->parameters['elementTagSize'] ?? 144) : '',
                        'fileHash' => $media->fileHash,
                        'filename' => $media->filename,
                        'filesize' => $media->filesize,