From fb411d6f32b75944dee2d2dc856dcc4950bd8eff Mon Sep 17 00:00:00 2001 From: Fredrik Jonsson Date: Tue, 14 Nov 2023 11:54:52 +0100 Subject: [PATCH] If with or heght is set in img and figure shortcodes, use that even when size is set. --- layouts/shortcodes/figure.html | 9 +++++++-- layouts/shortcodes/img.html | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/layouts/shortcodes/figure.html b/layouts/shortcodes/figure.html index 8ed3f41..efcac00 100644 --- a/layouts/shortcodes/figure.html +++ b/layouts/shortcodes/figure.html @@ -39,8 +39,13 @@ {{ if $size -}} {{ $image := $resource.Resize $size -}} {{ $src = $image.RelPermalink -}} - {{ $width = $image.Width -}} - {{ $height = $image.Height -}} + {{ if or $width $height -}} + {{ $realwidth = $image.Width -}} + {{ $realheight = $image.Height -}} + {{ else -}} + {{ $width = $image.Width -}} + {{ $height = $image.Height -}} + {{ end -}} {{ if $srcset -}} {{ $srcsetw = $srcsetw | append (printf "%s %sw" $src (strings.TrimRight "x" $size)) -}} {{ end -}} diff --git a/layouts/shortcodes/img.html b/layouts/shortcodes/img.html index 9ae48e2..64eb94e 100644 --- a/layouts/shortcodes/img.html +++ b/layouts/shortcodes/img.html @@ -35,8 +35,13 @@ {{ if $size -}} {{ $image := $resource.Resize $size -}} {{ $src = $image.RelPermalink -}} - {{ $width = $image.Width -}} - {{ $height = $image.Height -}} + {{ if or $width $height -}} + {{ $realwidth = $image.Width -}} + {{ $realheight = $image.Height -}} + {{ else -}} + {{ $width = $image.Width -}} + {{ $height = $image.Height -}} + {{ end -}} {{ if $srcset -}} {{ $srcsetw = $srcsetw | append (printf "%s %sw" $src (strings.TrimRight "x" $size)) -}} {{ end -}}