aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/partials/author-picture.html
blob: c269efc9ebeb46b69b0f4d2e28c8a688d2f4789c (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
{{- $file       := "/profile/picture.png" -}}
{{- $path       := print "public/" (partial "author-media-path.html" .) $file -}}
{{- $image      := resources.Get $path -}}
{{- $404image   := resources.Get "data/media/404.png" -}}
{{- $dimensions := "160x160" -}}
{{- $author     := partial "author-user.html" . }}

{{- with .Params.feed -}}
{{- else -}}
  {{- with $image -}}
    {{- $image = .Content | resources.FromString (print (partial "function-paths-media.html") "/" $author "/" (path.Base .)) -}}
    <source srcset="{{- ($image.Fit (print $dimensions " webp")).RelPermalink -}}" type="image/webp" />
    {{- end -}}
{{ end }}

<img
  loading="lazy"
  {{- with .Params.feed }}
  width="64"
  height="64"
  alt="{{ .name }}"
  src="{{ .image }}"
  {{ else }}
  {{ if fileExists $path }}
  {{- with $image -}}
  {{- $image = (.Content | resources.FromString (print (partial "function-paths-media.html") "/" $author "/" (path.Base .))).Fit $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" . }}"
  {{ end -}}
/>
{{- /* This comment removes trailing newlines and white spaces. */ -}}