diff options
Diffstat (limited to 'themes/default/layouts/partials/author-picture.html')
-rw-r--r-- | themes/default/layouts/partials/author-picture.html | 74 |
1 files changed, 38 insertions, 36 deletions
diff --git a/themes/default/layouts/partials/author-picture.html b/themes/default/layouts/partials/author-picture.html index b3b4125..ad878bf 100644 --- a/themes/default/layouts/partials/author-picture.html +++ b/themes/default/layouts/partials/author-picture.html @@ -1,41 +1,43 @@ -{{- $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" . -}} +{{- $author := partial "function-authors-data.html" . -}} +{{- $profile := $author.picture.profile -}} +{{- $file := not (urls.Parse $profile).Host -}} -{{- with .Params.feed -}} -{{- else -}} - {{- with $image -}} - {{- $image = .Content | resources.FromString (print (partial "function-paths.html" "media") "/" $author "/" (path.Base .)) -}} - <source srcset="{{- ($image.Fit (print $dimensions " webp")).RelPermalink -}}" type="image/webp" /> - {{- end -}} -{{ end }} +{{- if $file -}} + {{- $profile = print $author.user "/" $profile -}} +{{- end -}} + +{{- $image := partial "function-caches-images.html" + (dict + "Source" $profile + "Fit" "160x160" + "Target" (print (partial "function-paths.html" "media") "/" $author.user "/") + "Copy" (print (partial "function-paths.html" "media") "/" $author.user "/" (path.Base $profile)) + "OptimizedCopy" (print (partial "function-paths.html" "media") "/" $author.user "/" (path.BaseName $profile) ".webp") + ) +-}} + +{{- $width := $image.Width -}} +{{- $height := $image.Height -}} +{{- $source := $image.RelPermalink -}} +{{- $alternate := $author.name -}} +{{- $sourceset := $image.OptRelPermalink -}} + +{{- with .Params.feed.image -}} + {{- $width = "64" -}} + {{- $height = "64" -}} + {{- $source = $.Params.feed.image -}} + {{- $alternate = $.Params.feed.name -}} + {{- $sourceset = "" -}} +{{- end -}} + +{{- with $sourceset -}} +<source srcset="{{ $sourceset }}" type="image/webp" /> +{{- 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.html" "media") "/" $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 -}} + width="{{ $width }}" + height="{{ $height }}" + src="{{ $source }}" + alt="{{ $alternate }}" /> {{- /* This comment removes trailing newlines and white spaces. */ -}} |