Upcast `[wsm]` BBCode
authorAlexander Ebert <ebert@woltlab.com>
Mon, 8 May 2023 17:10:37 +0000 (19:10 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 8 May 2023 17:10:37 +0000 (19:10 +0200)
See WoltLab/editor#47

ts/WoltLabSuite/Core/Component/Ckeditor/Media.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Component/Ckeditor/Media.js

index 169c41ba042ad6a3d2a89f75412a1cf3fc9d317c..7e03fb0db15d67dff3dd7aceedd490c64a4b5747 100644 (file)
@@ -45,6 +45,17 @@ function uploadMedia(element: HTMLElement, file: File, abortController?: AbortCo
 export function setup(element: HTMLElement): void {
   listenToCkeditor(element)
     .setupConfiguration(({ configuration, features }) => {
+      (configuration as any).woltlabMedia = {
+        resolveMediaUrl(mediaId: number, mediaSize: string) {
+          let thumbnail = "";
+          if (mediaSize !== "original") {
+            thumbnail = `&thumbnail=${mediaSize}`;
+          }
+
+          return `${window.WSC_API_URL}index.php?media/${mediaId}/${thumbnail}`;
+        },
+      };
+
       if (features.attachment || !features.media) {
         return;
       }
index d765e5ec70246bacff1b13bccdbae4dfdf4dc510..43e90320e500cbb1a2db6853d43f747df0a7c823 100644 (file)
@@ -47,6 +47,15 @@ define(["require", "exports", "./Event"], function (require, exports, Event_1) {
     function setup(element) {
         (0, Event_1.listenToCkeditor)(element)
             .setupConfiguration(({ configuration, features }) => {
+            configuration.woltlabMedia = {
+                resolveMediaUrl(mediaId, mediaSize) {
+                    let thumbnail = "";
+                    if (mediaSize !== "original") {
+                        thumbnail = `&thumbnail=${mediaSize}`;
+                    }
+                    return `${window.WSC_API_URL}index.php?media/${mediaId}/${thumbnail}`;
+                },
+            };
             if (features.attachment || !features.media) {
                 return;
             }