blob: 9babf1d72554521cdaf55aedeb664d0525ff2d44 (
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
|
{{- $file := "/profile/header.jpg" -}}
{{- $path := print "public/" (partial "author-media-path.html" .) $file -}}
{{- $image := resources.Get $path -}}
{{- $404image := resources.Get "data/media/404.png" -}}
{{- $dimensions := "x600" -}}
{{- $author := partial "author-user.html" . }}
{{- with $image -}}
{{- $image = .Content | resources.FromString (print (partial "function-paths-media.html") "/" $author "/" (path.Base .)) -}}
<source srcset="{{- ($image.Resize (print $dimensions " webp")).RelPermalink -}}" type="image/webp" />
{{- end -}}
<img
{{ if fileExists $path }}
{{- with $image -}}
{{- $image = (.Content | resources.FromString (print (partial "function-paths-media.html") "/" $author "/" (path.Base .))).Resize $dimensions -}}
width="{{ $image.Width }}"
height="{{ $image.Height }}"
src="{{ $image.RelPermalink }}"
{{- else -}}
src="{{ .Site.BaseURL }}/{{ partial "author-media-path.html" . }}{{ $file }}"
{{ end }}
{{- else -}}
width="{{ $404image.Width }}"
height="{{ $404image.Height }}"
src="{{ $404image.RelPermalink }}"
{{- end }}
alt="{{ partial "author-name.html" . }}"
/>
{{- /* This comment removes trailing newlines and white spaces. */ -}}
|