aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/partials/author-header.html
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2022-06-09 23:28:10 -0400
committertdro <tdro@noreply.example.com>2022-06-09 23:28:10 -0400
commit32ea63de8f2f03ae8eb9975a40c56c61832018c4 (patch)
tree0f053cd8c114cb5810bca6c361ae6684538f6146 /themes/default/layouts/partials/author-header.html
parenta5d761ce013c38bb500807775b757e16c59fbaa8 (diff)
downloadcanory-32ea63de8f2f03ae8eb9975a40c56c61832018c4.tar.gz
canory-32ea63de8f2f03ae8eb9975a40c56c61832018c4.tar.bz2
canory-32ea63de8f2f03ae8eb9975a40c56c61832018c4.zip
themes/default/layouts/partials/author-header: Resize headers
Try webp first.
Diffstat (limited to 'themes/default/layouts/partials/author-header.html')
-rw-r--r--themes/default/layouts/partials/author-header.html25
1 files changed, 18 insertions, 7 deletions
diff --git a/themes/default/layouts/partials/author-header.html b/themes/default/layouts/partials/author-header.html
index 174d057..0261915 100644
--- a/themes/default/layouts/partials/author-header.html
+++ b/themes/default/layouts/partials/author-header.html
@@ -1,20 +1,31 @@
-{{- $file := "/profile/header.jpg" -}}
-{{- $path := print "content/" (partial "author-media-path.html" .) $file -}}
+{{- $file := "/profile/header.jpg" -}}
+{{- $path := print "public/" (partial "author-media-path.html" .) $file -}}
+{{- $image := resources.Get $path -}}
+{{- $404origin := print "/images/404.png" -}}
+{{- $404image := imageConfig (print "static/" $404origin) -}}
+{{- $dimensions := "x360" -}}
-{{- $404origin := print "/images/404.png" -}}
-{{- $404image := imageConfig (print "static/" $404origin) -}}
+{{- with $image -}}
+ {{- $image = .Content | resources.FromString (print "/data/static/images/" (. | urlize)) -}}
+ <source srcset="{{- ($image.Resize (print $dimensions " webp")).RelPermalink -}}" type="image/webp" />
+{{- end -}}
<img
loading="lazy"
- {{- if fileExists $path }}
- {{ $image := imageConfig $path -}}
+ {{ if fileExists $path }}
+ {{- with $image -}}
+ {{- $image = (.Content | resources.FromString (print "/data/static/images/" ($image | urlize))).Resize $dimensions -}}
width="{{ $image.Width }}"
height="{{ $image.Height }}"
+ src="{{ $image.RelPermalink }}"
+ {{- else -}}
src="{{ .Site.BaseURL }}/{{ partial "author-media-path.html" . }}{{ $file }}"
- {{- else }}
+ {{ end }}
+ {{- else -}}
width="{{ $404image.Width }}"
height="{{ $404image.Height }}"
src="{{ $404origin }}"
{{- end }}
alt="{{ partial "author-name.html" . }}"
/>
+{{- /* This comment removes trailing newlines and white spaces. */ -}}