From: Alexander Ebert Date: Thu, 1 Aug 2024 09:44:46 +0000 (+0200) Subject: Display the full image if thumbnails are not available X-Git-Tag: 6.1.0_Alpha_1~21 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=982bf625978c2fd97a6d73c16808c0bed4d95c6e;p=GitHub%2FWoltLab%2FWCF.git Display the full image if thumbnails are not available See https://www.woltlab.com/community/thread/307101-adding-an-attachment-recognition-problem/ --- 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"; }