Skip to content

Commit

Permalink
fix: use min o calculate size of embedded images.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Thulin committed Oct 4, 2024
1 parent 26c8848 commit ebaf16d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions library/Content/Images.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
)
]
]);
}
Expand All @@ -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'
)
]
]);
}
Expand Down

0 comments on commit ebaf16d

Please sign in to comment.