From 2f94208381df4e501a97492b1ee1710a4857db60 Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Thu, 29 Jul 2021 20:37:51 +0200 Subject: [PATCH] Show custom dimensions again --- ts/editor/ImageHandle.svelte | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/ts/editor/ImageHandle.svelte b/ts/editor/ImageHandle.svelte index c345ecfc1..b9a52858a 100644 --- a/ts/editor/ImageHandle.svelte +++ b/ts/editor/ImageHandle.svelte @@ -74,31 +74,22 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html height = activeImage!.clientHeight; /* we do not want the actual width, but rather the intended display width */ - const widthProperty = activeImage!.style.width; - let inPixel = false; + const widthAttribute = activeImage!.getAttribute("width"); customDimensions = false; - if (widthProperty) { - if (widthProperty.endsWith("px")) { - actualWidth = widthProperty.substring(0, widthProperty.length - 2); - inPixel = true; - } else { - actualWidth = widthProperty; - } - + if (widthAttribute) { + actualWidth = widthAttribute; customDimensions = true; } else { actualWidth = String(naturalWidth); } - const heightProperty = activeImage!.style.height; - if (inPixel || heightProperty === "auto") { - actualHeight = String(Math.trunc(Number(actualWidth) / aspectRatio)); - } else if (heightProperty) { - actualHeight = heightProperty.endsWith("px") - ? heightProperty.substring(0, heightProperty.length - 2) - : heightProperty; + const heightAttribute = activeImage!.getAttribute("height"); + if (heightAttribute) { + actualHeight = heightAttribute; customDimensions = true; + } else if (customDimensions) { + actualHeight = String(Math.trunc(Number(actualWidth) / aspectRatio)); } else { actualHeight = String(naturalHeight); }