aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/partials/author-card.html
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2022-06-07 01:48:02 -0400
committertdro <tdro@noreply.example.com>2022-06-07 01:48:02 -0400
commit04123b3bd9a7eebb1750411576ef396b2b76d29e (patch)
tree709534301175467173378b080e2432e8173356e5 /themes/default/layouts/partials/author-card.html
parentae842407a92a6e5bba5881ac798e3603e669a892 (diff)
downloadcanory-04123b3bd9a7eebb1750411576ef396b2b76d29e.tar.gz
canory-04123b3bd9a7eebb1750411576ef396b2b76d29e.tar.bz2
canory-04123b3bd9a7eebb1750411576ef396b2b76d29e.zip
themes/default/layouts/partials/author-picture: Optimize image sizes
Didn't intend to optimize now, but public assets are available. Take easy win and reduce initial payload.
Diffstat (limited to 'themes/default/layouts/partials/author-card.html')
-rw-r--r--themes/default/layouts/partials/author-card.html20
1 files changed, 18 insertions, 2 deletions
diff --git a/themes/default/layouts/partials/author-card.html b/themes/default/layouts/partials/author-card.html
index 23e007a..90e7781 100644
--- a/themes/default/layouts/partials/author-card.html
+++ b/themes/default/layouts/partials/author-card.html
@@ -1,3 +1,6 @@
+{{- $path := print "public/" .Data.user "/media/profile/picture.png" -}}
+{{- $image := resources.Get $path -}}
+
<micro-author>
<micro-card>
<micro-summary>
@@ -5,13 +8,26 @@
<figure>
<a title="{{ .Data.name }}" href="{{ "" | absURL }}/{{ .Data.user }}">
<picture>
+ {{- with $image }}
+ {{- $image = .Content | resources.FromString (print "/data/static/images/" ($image | urlize)) }}
+ <source srcset="{{- ($image.Resize "x64 png").RelPermalink -}}" type="image/png" />
+ <source srcset="{{- ($image.Resize "x64 jpg").RelPermalink -}}" type="image/jpeg" />
+ <source srcset="{{- ($image.Resize "x64 webp").RelPermalink -}}" type="image/webp" />
+ {{- end }}
<img
alt="{{ .Data.name }}"
- {{- if fileExists (print "content/" .Data.user "/media/profile/picture.png") }}
- src="{{ "" | absURL }}/{{ .Data.user }}/media/profile/picture.png"
+ {{- if fileExists $path }}
+ {{ with $image }}
+ {{- $image = (.Content | resources.FromString (print "/data/static/images/" ($image | urlize))).Resize "x64" -}}
+ width="{{ $image.Width }}"
+ height="{{ $image.Height }}"
+ src="{{ $image.RelPermalink }}"
+ {{- end }}
{{ else }}
{{- $404origin := print "/images/404.png" }}
{{- $404image := imageConfig (print "static/" $404origin) }}
+ width="{{ $404image.Width }}"
+ height="{{ $404image.Height }}"
src="{{ $404origin }}"
{{- end -}}
/>