scim-docs/themes/Indiiie/layouts/shortcodes/imgproc.html
timothe.jeanne 70942a402f
All checks were successful
/ build (push) Successful in 32s
/ deploy (push) Successful in 5s
img update v2
2024-11-06 14:39:38 +01:00

23 lines
No EOL
1,018 B
HTML

{{ $alt := .Get 1 | default "" }}
{{ $class := .Get 2 | default "" }}
{{ $imgpath := "images/" }}
{{- with $mainPath := .Get 0 }}
{{- with $i := resources.Get (printf "%s%s" $imgpath $mainPath) }}
{{ $resizedImage := $i.Process "resize 1920x" }}
<picture class="{{ $class}}">
{{ $smallpath := "images/small/" }}
{{- with $smallImage := resources.Get (printf "%s%s" $smallpath $mainPath ) }}
{{ $smallResized := $smallImage.Process "resize 1080x" }}
<source srcset="{{ $smallResized.RelPermalink }}" media="(max-width: 768px)">
{{- end}}
<img src="{{ $resizedImage.RelPermalink }}" alt="{{ $alt }}">
</picture>
{{- else }}
{{- errorf "The %q shortcode was unable to find %q. See %s" $.Name . $.Position }}
{{- end }}
{{- else }}
{{- errorf "The %q shortcode requires a positional parameter (0) indicating the image path, relative to the current page. See %s" $.Name $.Position }}
{{- end }}