From ebaf16d585da2825e7e46f6fa6fac5ce8744091c Mon Sep 17 00:00:00 2001 From: Sebastian Thulin Date: Fri, 4 Oct 2024 11:43:12 +0200 Subject: [PATCH] fix: use min o calculate size of embedded images. --- library/Content/Images.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/library/Content/Images.php b/library/Content/Images.php index 355726774..6d8c6d6a7 100644 --- a/library/Content/Images.php +++ b/library/Content/Images.php @@ -176,8 +176,10 @@ private static function replaceWithBladeTemplate($dom, $element, $image, $altTex 'imgAttributeList' => [ 'parsed' => true, ], - 'attributeList' => [ - 'style' => 'width: ' . $image->getAttribute('width') . 'px; max-width: 100%; height: auto;' + 'attributeList' => [ + 'style' => sprintf('width: min(%s, 100%%); height: auto;', + ($image->getAttribute('width') ?? 1920) . 'px' + ) ] ]); } @@ -190,10 +192,12 @@ private static function replaceWithBladeTemplate($dom, $element, $image, $altTex 'caption' => $captionText, 'classList' => explode(' ', $image->getAttribute('class') ?? []), 'imgAttributeList' => [ - 'parsed' => true, + 'parsed' => true ], - 'attributeList' => [ - 'style' => 'width: ' . $image->getAttribute('width') . 'px; max-width: 100%; height: auto;' + 'attributeList' => [ + 'style' => sprintf('width: min(%s, 100%%); height: auto;', + ($image->getAttribute('width') ?? 1920) . 'px' + ) ] ]); }