Display the full image if thumbnails are not available
authorAlexander Ebert <ebert@woltlab.com>
Thu, 1 Aug 2024 09:44:46 +0000 (11:44 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 1 Aug 2024 09:44:46 +0000 (11:44 +0200)
See https://www.woltlab.com/community/thread/307101-adding-an-attachment-recognition-problem/

ts/WoltLabSuite/Core/Component/Attachment/Entry.ts
ts/WoltLabSuite/Core/Component/File/woltlab-core-file.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Component/Attachment/Entry.js
wcfsetup/install/files/js/WoltLabSuite/Core/Component/File/woltlab-core-file.js

index a90175cfd8e223512a49ae5c620c9dd49a7a2513..494310421fb9bfaffbca646b7dcf5c7df168a5ed 100644 (file)
@@ -41,6 +41,8 @@ function fileInitializationCompleted(element: HTMLElement, file: WoltlabCoreFile
     const thumbnail = file.thumbnails.find((thumbnail) => thumbnail.identifier === "tiny");
     if (thumbnail !== undefined) {
       file.thumbnail = thumbnail;
+    } else if (file.link) {
+      file.previewUrl = file.link;
     }
 
     const url = file.thumbnails.find((thumbnail) => thumbnail.identifier === "")?.link;
index d54ee1f2e471e62ceffc703d28a391be9d815567..3870d0d325179e261059236511dd088f44861804 100644 (file)
@@ -211,6 +211,12 @@ export class WoltlabCoreFileElement extends HTMLElement {
     return this.dataset.previewUrl;
   }
 
+  set previewUrl(previewUrl: string) {
+    this.dataset.previewUrl = previewUrl;
+
+    this.#rebuildElement();
+  }
+
   get unbounded(): boolean {
     return this.getAttribute("dimensions") === "unbounded";
   }
index 4929fbc07effd39c02f18d726e717320dc220d38..12cd4dd4798d506509c12ad5dbee696e4240ff6e 100644 (file)
@@ -27,6 +27,9 @@ define(["require", "exports", "tslib", "WoltLabSuite/Core/Ui/Dropdown/Simple", "
             if (thumbnail !== undefined) {
                 file.thumbnail = thumbnail;
             }
+            else if (file.link) {
+                file.previewUrl = file.link;
+            }
             const url = file.thumbnails.find((thumbnail) => thumbnail.identifier === "")?.link;
             if (url !== undefined) {
                 insertButton = getInsertButton(data.attachmentID, url, editor);
index 3634dcaa8eb33a4b6026eb654b0fa9b1a3934570..bebeb4aac23cf7874c9ac68e8d0cc6925aba7172 100644 (file)
@@ -163,6 +163,10 @@ define(["require", "exports", "WoltLabSuite/Core/FileUtil"], function (require,
         get previewUrl() {
             return this.dataset.previewUrl;
         }
+        set previewUrl(previewUrl) {
+            this.dataset.previewUrl = previewUrl;
+            this.#rebuildElement();
+        }
         get unbounded() {
             return this.getAttribute("dimensions") === "unbounded";
         }