diff --git a/layouts/partials/paige/img.html b/layouts/partials/paige/img.html
index 65926ec0..0066ecaf 100644
--- a/layouts/partials/paige/img.html
+++ b/layouts/partials/paige/img.html
@@ -7,6 +7,7 @@
{{ $fingerprint := $params.fingerprint | default true }}
{{ $height := $params.height }}
{{ $loading := $params.loading | default "lazy" }}
+{{ $maxheight := $params.maxheight }}
{{ $maxwidth := $params.maxwidth }}
{{ $method := $params.method }}
{{ $options := $params.options }}
@@ -56,11 +57,11 @@
{{ $src = $resource.RelPermalink }}
{{ end }}
-{{ if and $height (not (or $maxwidth $width)) }}
+{{ if and (or $height $maxheight) (not (or $maxwidth $width)) }}
{{ $width = "auto" }}
{{ end }}
-{{ if and (or $maxwidth $width) (not $height) }}
+{{ if and (or $maxwidth $width) (not (or $height $maxheight)) }}
{{ $height = "auto" }}
{{ end }}
@@ -74,6 +75,16 @@
{{ end }}
{{ end }}
+{{ if $maxheight }}
+ {{ with printf "max-height: %v" $maxheight }}
+ {{ if $style }}
+ {{ $style = printf "%v; %v" $style . }}
+ {{ else }}
+ {{ $style = . }}
+ {{ end }}
+ {{ end }}
+{{ end }}
+
{{ if $maxwidth }}
{{ with printf "max-width: %v" $maxwidth }}
{{ if $style }}
diff --git a/layouts/shortcodes/paige/gallery.html b/layouts/shortcodes/paige/gallery.html
index 853a7fe3..8501965d 100644
--- a/layouts/shortcodes/paige/gallery.html
+++ b/layouts/shortcodes/paige/gallery.html
@@ -2,6 +2,7 @@
{{ $height := .Get "height" }}
{{ $images := .Get 0 | default (.Get "images") }}
{{ $justify := .Get "justify" | default "center" }}
+{{ $maxheight := .Get "maxheight" }}
{{ $maxwidth := .Get "maxwidth" }}
{{ $method := .Get "method" | default "resize" }}
{{ $options := .Get "options" | default "550x webp picture Lanczos" }}
@@ -39,6 +40,7 @@
{{ partial "paige/a.html" (dict
"content" (partial "paige/img.html" (dict
"height" $height
+ "maxheight" $maxheight
"maxwidth" $maxwidth
"method" $method
"options" $options
@@ -61,6 +63,7 @@
{{ partial "paige/a.html" (dict
"content" (partial "paige/img.html" (dict
"height" $height
+ "maxheight" $maxheight
"maxwidth" $maxwidth
"method" $method
"options" $options