From 7e5b6aba4ab892b19565454c7381010b702ff802 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Sat, 8 Jan 2022 02:47:12 +0100 Subject: [PATCH] Reset .style.width when resizing images (#1579) --- ts/editor/image-overlay/ImageHandle.svelte | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ts/editor/image-overlay/ImageHandle.svelte b/ts/editor/image-overlay/ImageHandle.svelte index 6dc429a9e..4d5cd4e06 100644 --- a/ts/editor/image-overlay/ImageHandle.svelte +++ b/ts/editor/image-overlay/ImageHandle.svelte @@ -155,6 +155,17 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html width = Math.trunc(naturalWidth! * (height / naturalHeight!)); } + /** + * Image resizing add-ons previously used image.style.width to set the + * preferred width of an image. In these cases, if we'd only set + * image.width, there would be no visible effect on the image. + * To avoid confusion with users we'll clear image.style.width (for now). + */ + activeImage!.style.removeProperty("width"); + if (activeImage!.getAttribute("style")?.length === 0) { + activeImage!.removeAttribute("style"); + } + activeImage!.width = width; }