diff options
author | tdro <tdro@noreply.example.com> | 2022-06-07 01:48:02 -0400 |
---|---|---|
committer | tdro <tdro@noreply.example.com> | 2022-06-07 01:48:02 -0400 |
commit | 04123b3bd9a7eebb1750411576ef396b2b76d29e (patch) | |
tree | 709534301175467173378b080e2432e8173356e5 /themes/default/layouts/partials/author-picture.html | |
parent | ae842407a92a6e5bba5881ac798e3603e669a892 (diff) | |
download | canory-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-picture.html')
-rw-r--r-- | themes/default/layouts/partials/author-picture.html | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/themes/default/layouts/partials/author-picture.html b/themes/default/layouts/partials/author-picture.html index 88dc0df..74347fa 100644 --- a/themes/default/layouts/partials/author-picture.html +++ b/themes/default/layouts/partials/author-picture.html @@ -1,18 +1,18 @@ -{{- $file := "/profile/picture.png" -}} -{{- $path := print "content/" (partial "author-media-path.html" .) $file -}} - +{{- $file := "/profile/picture.png" -}} +{{- $path := print "public/" (partial "author-media-path.html" .) $file -}} +{{- $image := resources.Get $path -}} {{- $404origin := print "/images/404.png" -}} -{{- $404image := imageConfig (print "static/" $404origin) -}} +{{- $404image := imageConfig (print "static/" $404origin) -}} -{{- if fileExists $path }} - {{- $image := imageConfig $path -}} - {{- with .Params.feed -}} - {{ else }} - <source srcset="{{ .Site.BaseURL }}/{{ partial "author-media-path.html" . }}/profile/picture.png" type="image/png" /> - <source srcset="{{ .Site.BaseURL }}/{{ partial "author-media-path.html" . }}/profile/picture.jpg" type="image/jpeg" /> - <source srcset="{{ .Site.BaseURL }}/{{ partial "author-media-path.html" . }}/profile/picture.webp" type="image/webp" /> - {{ end }} -{{- end -}} +{{- with .Params.feed -}} +{{- else -}} + {{- 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 -}} +{{ end }} <img loading="lazy" @@ -23,10 +23,14 @@ src="{{ .image }}" {{ else }} {{ if fileExists $path }} - {{- $image := imageConfig $path -}} + {{- with $image -}} + {{- $image = (.Content | resources.FromString (print "/data/static/images/" ($image | urlize))).Resize "x64" -}} 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 }}" |