23 lines
No EOL
1,018 B
HTML
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 }} |