Find an image named "thumbnail" if none is given as a param
This commit is contained in:
parent
4231c6c5d8
commit
fe8e12a2ba
2 changed files with 6 additions and 2 deletions
|
@ -1,5 +1,7 @@
|
||||||
{{- $thumbnailResource := .Resources.GetMatch (index .Page.Params "thumbnail")
|
{{- $thumbnailResource := .Page.Resources.GetMatch
|
||||||
|
(index .Page.Params "thumbnail" | default "[tT]humbnail*")
|
||||||
| default (index (.Page.Resources.ByType "image") 0) -}}
|
| default (index (.Page.Resources.ByType "image") 0) -}}
|
||||||
|
|
||||||
{{- if not $thumbnailResource -}}
|
{{- if not $thumbnailResource -}}
|
||||||
{{- errorf "No thumbnail available for %s" .Page.Permalink }}
|
{{- errorf "No thumbnail available for %s" .Page.Permalink }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
|
@ -3,11 +3,13 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ define "main" }}
|
{{ define "main" }}
|
||||||
|
{{- $photos := where (.Resources.ByType "image")
|
||||||
|
"Name" "not in" (slice "thumbnail" "Thumbnail" "thumbnail.jpg" "Thumbnail.jpg") -}}
|
||||||
|
|
||||||
{{- if .Title -}}
|
{{- if .Title -}}
|
||||||
{{ partial "content_header.html" . }}
|
{{ partial "content_header.html" . }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{ $photos := .Resources.ByType "image" }}
|
|
||||||
{{ if eq (len $photos) 0 }}
|
{{ if eq (len $photos) 0 }}
|
||||||
{{ errorf "Missing photo from photos page %q" .Path }}
|
{{ errorf "Missing photo from photos page %q" .Path }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue