blob: 593c4e0b6dba2fdc55b9f8588b7af0d81759e85c (
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
{{ $file := .Params.cover }}
{{ $altText := .Params.coverAlt }}
{{ $destination := $file }}
<!-- Image processing configuration -->
{{ $imgProcConfig := partialCached "utilities/image-processing-config" . }}
<!-- Default image path -->
{{ $imgPath := .Page.Param "imgPath" }}
{{ if $imgPath }}
{{ $file = path.Join $imgPath .Params.cover }}
{{ end }}
{{ $inputFile := .Page.Resources.GetMatch $file }}
{{ with partial "utilities/image-processing" (dict "context" . "input" $inputFile "config" $imgProcConfig) }}
{{ if .sets.default }}
<picture>
<!-- Extra sets -->
{{ range .sets.extra }}
<source
srcset='{{ delimit .source ", " }}'
type="{{ .mediaType }}"
>
{{ end }}
<!-- Default set -->
<source
srcset='{{ delimit .sets.default ", " }}'
type="{{ .default.MediaType }}"
>
<img
class="cover"
{{ with .default }}
src="{{ .RelPermalink }}"
width="{{ .Width }}"
height="{{ .Height }}"
{{ end }}
{{ with $altText }}alt="{{ . }}"{{ end }}
>
</picture>
{{ else }}
<!-- Avoid trying to get width and height from SVG files -->
{{ if .input }}
<img
class="cover"
{{ with .input }}
src="{{ .RelPermalink }}"
{{ if ne .MediaType.SubType "svg" }}
width="{{ .Width }}"
height="{{ .Height }}"
{{ end }}
{{ end }}
{{ with $altText }}alt="{{ . }}"{{ end }}
>
{{ else }}
<!-- If local file isn't found, assume it's a remote file -->
{{ with ($destination | safeURL) }}
<img
class="cover"
src="{{ . }}"
{{ with $altText }}alt="{{ . }}"{{ end }}
>
{{ end }}
{{ end }}
{{ end }}
{{ end }}
|