blob: 79e6b08801ca6ed56e54d0cd6a175299f5421af7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
{{$imageBundle := .page.Site.GetPage "uploads"}}
{{with .image}}
{{$path := .url}}
{{$media := .media}}
{{$alt := .alt}}
{{$srcset := slice}}
{{with .params}}
{{range (last (sub (len .) 1) .)}}
{{$image := partial "func/GetImage" (dict "bundle" $imageBundle "path" $path "cmd" .cmd "options" .options)}}
{{$width := index (split .options "x") 0}}
{{$srcset = $srcset | append (print ($image.RelPermalink) " " $width "w")}}
{{end}}
{{end}}
<picture{{with .class}} class="{{.}}"{{end}}>
{{with $srcset}}
<source{{with $media}} media="{{.}}"{{end}} srcset="{{delimit $srcset ", "}}" />
{{end}}
{{if .params}}
{{with (index .params 0)}}
{{$image := partial "func/GetImage" (dict "bundle" $imageBundle "path" $path "cmd" .cmd "options" .options)}}
<img src="{{$image.RelPermalink | default ($path | relURL)}}" alt="{{$alt}}" />
{{end}}
{{else}}
<img src="{{$path | relURL}}" alt="{{$alt}}" />
{{end}}
</picture>
{{end}}
|