From 982bf625978c2fd97a6d73c16808c0bed4d95c6e Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 1 Aug 2024 11:44:46 +0200 Subject: [PATCH] Display the full image if thumbnails are not available See https://www.woltlab.com/community/thread/307101-adding-an-attachment-recognition-problem/ --- ts/WoltLabSuite/Core/Component/Attachment/Entry.ts | 2 ++ ts/WoltLabSuite/Core/Component/File/woltlab-core-file.ts | 6 ++++++ .../js/WoltLabSuite/Core/Component/Attachment/Entry.js | 3 +++ .../WoltLabSuite/Core/Component/File/woltlab-core-file.js | 4 ++++ 4 files changed, 15 insertions(+) diff --git a/ts/WoltLabSuite/Core/Component/Attachment/Entry.ts b/ts/WoltLabSuite/Core/Component/Attachment/Entry.ts index a90175cfd8..494310421f 100644 --- a/ts/WoltLabSuite/Core/Component/Attachment/Entry.ts +++ b/ts/WoltLabSuite/Core/Component/Attachment/Entry.ts @@ -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; diff --git a/ts/WoltLabSuite/Core/Component/File/woltlab-core-file.ts b/ts/WoltLabSuite/Core/Component/File/woltlab-core-file.ts index d54ee1f2e4..3870d0d325 100644 --- a/ts/WoltLabSuite/Core/Component/File/woltlab-core-file.ts +++ b/ts/WoltLabSuite/Core/Component/File/woltlab-core-file.ts @@ -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"; } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Attachment/Entry.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Attachment/Entry.js index 4929fbc07e..12cd4dd479 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Attachment/Entry.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Component/Attachment/Entry.js @@ -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); diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Component/File/woltlab-core-file.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Component/File/woltlab-core-file.js index 3634dcaa8e..bebeb4aac2 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Component/File/woltlab-core-file.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Component/File/woltlab-core-file.js @@ -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"; } -- 2.20.1