aboutsummaryrefslogtreecommitdiff
path: root/themes/default/layouts/partials/author-picture.html
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2022-06-01 19:16:58 -0400
committertdro <tdro@noreply.example.com>2022-06-01 19:16:58 -0400
commit473a08150b875112c522522e21fb542d3ec26736 (patch)
treeec1d5f7c9e7ce80d5d2073490ff6a35f5351b6a1 /themes/default/layouts/partials/author-picture.html
parentdff47d17bb0ed4479bfb187b19ba1c8b1fa61226 (diff)
downloadcanory-473a08150b875112c522522e21fb542d3ec26736.tar.gz
canory-473a08150b875112c522522e21fb542d3ec26736.tar.bz2
canory-473a08150b875112c522522e21fb542d3ec26736.zip
themes/default/layouts: Handle image search errors
Namespace 404 image processing.
Diffstat (limited to 'themes/default/layouts/partials/author-picture.html')
-rw-r--r--themes/default/layouts/partials/author-picture.html34
1 files changed, 24 insertions, 10 deletions
diff --git a/themes/default/layouts/partials/author-picture.html b/themes/default/layouts/partials/author-picture.html
index e288410..88dc0df 100644
--- a/themes/default/layouts/partials/author-picture.html
+++ b/themes/default/layouts/partials/author-picture.html
@@ -1,12 +1,18 @@
-{{- $file := "/profile/picture.png" -}}
-{{- $image := imageConfig (print "content/" (partial "author-media-path.html" .) $file) -}}
+{{- $file := "/profile/picture.png" -}}
+{{- $path := print "content/" (partial "author-media-path.html" .) $file -}}
-{{- 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 }}
+{{- $404origin := print "/images/404.png" -}}
+{{- $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 -}}
<img
loading="lazy"
@@ -16,9 +22,17 @@
alt="{{ .name }}"
src="{{ .image }}"
{{ else }}
+ {{ if fileExists $path }}
+ {{- $image := imageConfig $path -}}
width="{{ $image.Width }}"
height="{{ $image.Height }}"
- alt="{{ partial "author-name.html" . }}"
src="{{ .Site.BaseURL }}/{{ partial "author-media-path.html" . }}{{ $file }}"
- {{ end }}
+ {{- else -}}
+ width="{{ $404image.Width }}"
+ height="{{ $404image.Height }}"
+ src="{{ $404origin }}"
+ {{- end }}
+ alt="{{ partial "author-name.html" . }}"
+ {{ end -}}
/>
+{{- /* This comment removes trailing newlines and white spaces. */ -}}