Fix/Improve code for media insertion into editor
authorMatthias Schmidt <gravatronics@live.com>
Mon, 5 Sep 2016 19:02:21 +0000 (21:02 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Mon, 5 Sep 2016 19:02:21 +0000 (21:02 +0200)
wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Editor.js

index 5f2e782d67e419336a0241789f8c0b638dae42a5..5f50d7a14938fc83adb08e42f5e0087d95576597 100644 (file)
@@ -263,7 +263,7 @@ define(['Core', 'Dictionary', 'Dom/Traverse', 'Language', 'Ui/Dialog', 'WoltLabS
                                for (var i = 0; i < 4; i++) {
                                        size = sizes[i];
                                        
-                                       if (item[size + 'ThumbnailHeight']) {
+                                       if (item[size + 'ThumbnailHeight'] != 0) {
                                                available = size;
                                                
                                                if (thumbnailSize == size) {
@@ -274,12 +274,14 @@ define(['Core', 'Dictionary', 'Dom/Traverse', 'Language', 'Ui/Dialog', 'WoltLabS
                                
                                thumbnailSize = available;
                                
-                               if (!thumbnailSize || thumbnailSize === 'original') {
-                                       this._options.editor.insert.html('<img src="' + item.link + '" class="woltlabSuiteMedia" data-media-id="' + item.mediaID + '" data-media-size="' + thumbnailSize + '">');
-                               }
-                               else {
-                                       this._options.editor.insert.html('<img src="' + item[thumbnailSize + 'ThumbnailLink'] + '" class="woltlabSuiteMedia" data-media-id="' + item.mediaID + '" data-media-size="' + thumbnailSize + '">');
+                               if (!thumbnailSize) thumbnailSize = 'original';
+                               
+                               var link = item.link;
+                               if (thumbnailSize !== 'original') {
+                                       link = item[thumbnailSize + 'ThumbnailLink'];
                                }
+                               
+                               this._options.editor.insert.html('<img src="' + item.link + '" class="woltlabSuiteMedia" data-media-id="' + item.mediaID + '" data-media-size="' + thumbnailSize + '">');
                        }
                        else {
                                this._options.editor.insert.text("[wsm='" + item.mediaID + "'][/wsm]");