From 44bc078ad45f9f0b826570729f8f143c10838dfd Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Sat, 17 Aug 2019 13:58:02 +0200 Subject: [PATCH] Fix small media image previews directly after upload See #2576 See #3035 --- .../Core/Controller/Media/List.js | 3 ++- .../js/WoltLabSuite/Core/Media/Upload.js | 21 ++++++++++++------- .../lib/data/media/MediaAction.class.php | 3 ++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Media/List.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Media/List.js index 1d1a8c8893..b7a2045bbb 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Media/List.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Media/List.js @@ -49,7 +49,8 @@ define([ options = options || {}; _upload = new MediaListUpload('uploadButton', 'mediaListTableBody', { categoryId: options.categoryId, - multiple: true + multiple: true, + elementTagSize: 48 }); MediaClipboard.init( diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Upload.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Upload.js index 1c97c2201c..3dd1faa5ca 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Upload.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Media/Upload.js @@ -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', ''); diff --git a/wcfsetup/install/files/lib/data/media/MediaAction.class.php b/wcfsetup/install/files/lib/data/media/MediaAction.class.php index 40c06243bd..7cc233e20b 100644 --- a/wcfsetup/install/files/lib/data/media/MediaAction.class.php +++ b/wcfsetup/install/files/lib/data/media/MediaAction.class.php @@ -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, -- 2.20.1