scim-docs/themes/Indiiie/layouts/shortcodes/imgproc.html

23 lines
1,016 B
HTML
Raw Normal View History

2024-11-04 16:07:02 +00:00
{{ $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 720x" }}
<picture class="{{ $class}}">
{{ $smallpath := "images/small/" }}
{{- with $smallImage := resources.Get (printf "%s%s" $smallpath $mainPath ) }}
{{ $smallResized := $smallImage.Process "resize 720x" }}
<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 }}