Add maxheight, maxwidth params

This commit is contained in:
Will Faught
2023-01-10 21:08:25 -08:00
parent 02a80777e9
commit c3051e027f
5 changed files with 87 additions and 3 deletions

View File

@@ -2,6 +2,8 @@
{{ $caption := .caption }}
{{ $height := .height }}
{{ $link := .link }}
{{ $maxheight := .maxheight }}
{{ $maxwidth := .maxwidth }}
{{ $method := .method }}
{{ $options := .options }}
{{ $page := .page }}
@@ -20,6 +22,8 @@
"alt" $alt
"class" $class
"height" $height
"maxheight" $maxheight
"maxwidth" $maxwidth
"method" $method
"options" $options
"page" $page

View File

@@ -51,4 +51,52 @@
{{ $src = $resource.RelPermalink }}
{{ end }}
{{ if and (or $height $maxheight) (not (or $maxwidth $width)) }}
{{ $width = "auto" }}
{{ end }}
{{ if and (or $maxwidth $width) (not (or $height $maxheight)) }}
{{ $height = "auto" }}
{{ end }}
{{ if $height }}
{{ with printf "height: %v" $height }}
{{ if $style }}
{{ $style = printf "%v; %v" $style . }}
{{ else }}
{{ $style = . }}
{{ end }}
{{ 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 }}
{{ $style = printf "%v; %v" $style . }}
{{ else }}
{{ $style = . }}
{{ end }}
{{ end }}
{{ end }}
{{ if $width }}
{{ with printf "width: %v" $width }}
{{ if $style }}
{{ $style = printf "%v; %v" $style . }}
{{ else }}
{{ $style = . }}
{{ end }}
{{ end }}
{{ end }}
<img {{ with $alt }} alt="{{ . }}" {{ end }} {{ with $class }} class="{{ . }}" {{ end }} crossorigin="{{ $crossorigin }}" {{ with $fetchpriority }} fetchpriority="{{ . }}" {{ end }} {{ with $intrinsicheight }} height="{{ . }}" {{ end }} loading="{{ $loading }}" referrerpolicy="{{ $referrerpolicy }}" src="{{ $src }}" {{ with $style }} style="{{ . | safeCSS }}" {{ end }} {{ with $title }} title="{{ . }}" {{ end }} {{ with $intrinsicwidth }} width="{{ . }}" {{ end }}>