aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/partials/author-picture.html
blob: 9153e0888cd000f56c72ea04a5dfa4638e4f778f (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
{{- $author := partial "function-authors-data.html" . -}}
{{- $metadata := print "public/" $author.user "/author.json" -}}

{{- $alternate := $author.name -}}
{{- $width := "" -}}
{{- $height := "" -}}
{{- $source := "" -}}
{{- $sourceset := "" -}}

{{- with .Params.feed.favicon -}}
  {{- $alternate = $.Params.feed.name -}}
  {{- $width = "64" -}}
  {{- $height = "64" -}}
  {{- $source = print "/" (partial "function-paths.html").media "/favicon." ($.Params.feed.source | anchorize) ".png" -}}
  {{- if not (fileExists (print "public/" $source)) -}}
    {{- $source = $.Params.feed.favicon -}}
  {{- end -}}
  {{- $sourceset = "" -}}
{{- else -}}
  {{- $source = print "/" (partial "function-paths.html").media "/" $author.user "/" $author.user "-profile" (path.Ext $author.picture.profile) -}}
  {{- $sourceset = print "/" (partial "function-paths.html").media "/" $author.user "/" $author.user "-profile.webp" -}}
  {{- with $metadata := resources.Get $metadata -}}
    {{- $metadata = $metadata.Content | transform.Unmarshal -}}
    {{- $width = $metadata.picture.profileWidth -}}
    {{- $height = $metadata.picture.profileHeight -}}
  {{- else -}}
    {{- $source = "/data/media/404.png" -}}
    {{- $sourceset = "" -}}
  {{- end -}}
{{- end -}}

{{- if not (path.Ext $author.picture.profile) -}}
  {{- $source = "/data/media/404.png" -}}
  {{- $sourceset = "" -}}
{{- end -}}

{{- with $sourceset -}}
<source srcset="{{ print ("" | absURL) $sourceset }}" type="image/webp" />
{{- end -}}

<img
  width="{{ $width }}"
  height="{{ $height }}"
  src="{{ print ("" | absURL) $source }}"
  alt="{{ $alternate }}"
/>
{{- /* This comment removes trailing newlines and white spaces. */ -}}