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}