From 4142fa2aa22746fa1e252f4bae4948d26f93491d Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Wed, 21 Jul 2021 19:03:21 +0200 Subject: [PATCH] Don't show same dimensions twice if there are no custom dimensions --- ts/editor/ImageHandle.svelte | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ts/editor/ImageHandle.svelte b/ts/editor/ImageHandle.svelte index d6934c093..2eb20e33c 100644 --- a/ts/editor/ImageHandle.svelte +++ b/ts/editor/ImageHandle.svelte @@ -27,6 +27,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html let actualWidth = ""; let actualHeight = ""; + let customDimensions = false; let containerTop = 0; let containerLeft = 0; @@ -71,12 +72,15 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html height = image!.clientHeight; const widthProperty = image!.style.width; + customDimensions = false; + if (widthProperty) { actualWidth = widthProperty.endsWith("px") ? widthProperty.substring(0, widthProperty.length - 2) : widthProperty; + customDimensions = true; } else { - actualWidth = String(width); + actualWidth = String(naturalWidth); } const heightProperty = image!.style.height; @@ -84,8 +88,9 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html actualHeight = heightProperty.endsWith("px") ? heightProperty.substring(0, heightProperty.length - 2) : heightProperty; + customDimensions = true; } else { - actualHeight = String(height); + actualHeight = String(naturalHeight); } } @@ -162,7 +167,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html {#if showDimensions}
- {actualWidth}×{actualHeight} (Original: {naturalWidth}×{naturalHeight}) + {actualWidth}×{actualHeight} + {#if customDimensions}(Original: {naturalWidth}×{naturalHeight}){/if}
{/if}