From 28da38309067c98bbb2928aa35ee365c3d41a36f Mon Sep 17 00:00:00 2001 From: Agos95 Date: Wed, 24 Aug 2022 10:41:57 +0200 Subject: [PATCH 1/6] flexible featured image start --- modules/wowchemy/layouts/partials/page_header.html | 11 +++++++++++ modules/wowchemy/layouts/partials/views/compact.html | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/modules/wowchemy/layouts/partials/page_header.html b/modules/wowchemy/layouts/partials/page_header.html index 33357697c..4c2195dd4 100644 --- a/modules/wowchemy/layouts/partials/page_header.html +++ b/modules/wowchemy/layouts/partials/page_header.html @@ -1,5 +1,15 @@ + {{ $page := . }} +{{/* Search for an image "*featured*" in post folder */}} {{ $featured := (.Resources.ByType "image").GetMatch "*featured*" }} +{{/* Otherwise fall back the image file specified in front matter */}} +{{ if eq $featured nil }} + {{/* First search in post folder */}} + {{ $featured = (.Resources.ByType "image").GetMatch .Params.image.filename }} + {{/* Otherwise in media/ folder */}} + {{ if eq $featured nil}} {{ $featured = resources.GetMatch (path.Join "media" .Params.image.filename) }} {{ end }} +{{end}} + {{ $anchor := $page.Params.image.focal_point | default "Smart" }} {{/* Set default titles for node pages */}} @@ -97,3 +107,4 @@

{{ $title }}

{{end}} {{end}} + \ No newline at end of file diff --git a/modules/wowchemy/layouts/partials/views/compact.html b/modules/wowchemy/layouts/partials/views/compact.html index 13e2626b9..8b9f67e8c 100644 --- a/modules/wowchemy/layouts/partials/views/compact.html +++ b/modules/wowchemy/layouts/partials/views/compact.html @@ -1,3 +1,4 @@ + {{ $item := .item }} {{/* Dynamic view adjusts to content type. */}} @@ -74,7 +75,15 @@
+ {{/* Search for an image "*featured*" in post folder */}} {{ $resource := ($item.Resources.ByType "image").GetMatch "*featured*" }} + {{/* Otherwise fall back the image file specified in front matter */}} + {{ if eq $resource nil }} + {{/* First search in post folder */}} + {{ $resource = ($item.Resources.ByType "image").GetMatch $item.Params.image.filename }} + {{/* Otherwise in media/ folder */}} + {{ if eq $resource nil}} {{ $resource = resources.GetMatch (path.Join "media" $item.Params.image.filename) }} {{ end }} + {{ end }} {{ with $resource }} {{ $image := .Resize "150x webp" }} @@ -84,3 +93,4 @@ {{end}}
+ \ No newline at end of file From 9eb62bc8505b1558c675dbe861bcd83e438f04be Mon Sep 17 00:00:00 2001 From: Agos95 Date: Wed, 24 Aug 2022 14:06:12 +0200 Subject: [PATCH 2/6] update views for flexible featured images --- .../wowchemy/layouts/partials/views/card.html | 23 +++++++++++++------ .../layouts/partials/views/compact.html | 19 +++++++-------- .../layouts/partials/views/masonry.html | 9 ++++++++ .../layouts/partials/views/showcase.html | 20 ++++++++++++---- 4 files changed, 50 insertions(+), 21 deletions(-) diff --git a/modules/wowchemy/layouts/partials/views/card.html b/modules/wowchemy/layouts/partials/views/card.html index 4cd6cd0f0..fb22e8cea 100644 --- a/modules/wowchemy/layouts/partials/views/card.html +++ b/modules/wowchemy/layouts/partials/views/card.html @@ -41,16 +41,25 @@ {{ partial "page_metadata" (dict "page" $item "is_list" 1) }} {{ end }} + {{/* Search for an image "*featured*" in post folder */}} {{ $resource := ($item.Resources.ByType "image").GetMatch "*featured*" }} + {{/* Otherwise fall back the image file specified in front matter */}} + {{ $filename := $item.Params.image.filename }} + {{ if eq $resource nil }} + {{/* First search in post folder */}} + {{ $resource = ($item.Resources.ByType "image").GetMatch $filename }} + {{/* Otherwise in media/ folder */}} + {{ if eq $resource nil}} {{ $resource = resources.GetMatch (path.Join "media" $filename) }} {{ end }} + {{ end }} {{ $anchor := $item.Params.image.focal_point | default "Smart" }} {{ with $resource }} - {{ $image := .Fill (printf "808x455 webp %s" $anchor) }} - -
- {{ $item.Title }} -
-
+ {{ $image := .Fill (printf "808x455 webp %s" $anchor) }} + +
+ {{ $item.Title }} +
+
{{end}}
diff --git a/modules/wowchemy/layouts/partials/views/compact.html b/modules/wowchemy/layouts/partials/views/compact.html index 8b9f67e8c..7baf44c06 100644 --- a/modules/wowchemy/layouts/partials/views/compact.html +++ b/modules/wowchemy/layouts/partials/views/compact.html @@ -78,18 +78,19 @@ {{/* Search for an image "*featured*" in post folder */}} {{ $resource := ($item.Resources.ByType "image").GetMatch "*featured*" }} {{/* Otherwise fall back the image file specified in front matter */}} + {{ $filename := $item.Params.image.filename }} {{ if eq $resource nil }} - {{/* First search in post folder */}} - {{ $resource = ($item.Resources.ByType "image").GetMatch $item.Params.image.filename }} - {{/* Otherwise in media/ folder */}} - {{ if eq $resource nil}} {{ $resource = resources.GetMatch (path.Join "media" $item.Params.image.filename) }} {{ end }} + {{/* First search in post folder */}} + {{ $resource = ($item.Resources.ByType "image").GetMatch $filename }} + {{/* Otherwise in media/ folder */}} + {{ if eq $resource nil}} {{ $resource = resources.GetMatch (path.Join "media" $filename) }} {{ end }} {{ end }} {{ with $resource }} - {{ $image := .Resize "150x webp" }} - - {{ $item.Title }} - + {{ $image := .Resize "150x webp" }} + + {{ $item.Title }} + {{end}}
diff --git a/modules/wowchemy/layouts/partials/views/masonry.html b/modules/wowchemy/layouts/partials/views/masonry.html index d7d89323c..da02f4e02 100644 --- a/modules/wowchemy/layouts/partials/views/masonry.html +++ b/modules/wowchemy/layouts/partials/views/masonry.html @@ -18,7 +18,16 @@ {{ $summary = $item.Summary }} {{ end }} +{{/* Search for an image "*featured*" in post folder */}} {{ $resource := ($item.Resources.ByType "image").GetMatch "*featured*" }} +{{/* Otherwise fall back the image file specified in front matter */}} +{{ $filename := $item.Params.image.filename }} +{{ if eq $resource nil }} + {{/* First search in post folder */}} + {{ $resource = ($item.Resources.ByType "image").GetMatch $filename }} + {{/* Otherwise in media/ folder */}} + {{ if eq $resource nil}} {{ $resource = resources.GetMatch (path.Join "media" $filename) }} {{ end }} +{{ end }}
{{ with $resource }} diff --git a/modules/wowchemy/layouts/partials/views/showcase.html b/modules/wowchemy/layouts/partials/views/showcase.html index 870367f8a..b3ad8b117 100644 --- a/modules/wowchemy/layouts/partials/views/showcase.html +++ b/modules/wowchemy/layouts/partials/views/showcase.html @@ -49,13 +49,23 @@
+ {{/* Search for an image "*featured*" in post folder */}} {{ $resource := ($item.Resources.ByType "image").GetMatch "*featured*" }} + {{/* Otherwise fall back the image file specified in front matter */}} + {{ $filename := $item.Params.image.filename }} + {{ if eq $resource nil }} + {{/* First search in post folder */}} + {{ $resource = ($item.Resources.ByType "image").GetMatch $filename }} + {{/* Otherwise in media/ folder */}} + {{ if eq $resource nil}} {{ $resource = resources.GetMatch (path.Join "media" $filename) }} {{ end }} + {{ end }} + {{ with $resource }} - {{ $image := .Resize "540x webp" }} - {{if $do_link}}{{end}} - {{ $item.Title }} - {{if $do_link}}{{end}} + {{ $image := .Resize "540x webp" }} + {{if $do_link}}{{end}} + {{ $item.Title }} + {{if $do_link}}{{end}} {{end}}
From 2a2d7f2b9e085fbaa4926cd3035f64dfec28f06d Mon Sep 17 00:00:00 2001 From: Agos95 Date: Wed, 24 Aug 2022 16:26:54 +0200 Subject: [PATCH 3/6] fix flexible featured image --- .../wowchemy/layouts/partials/jsonld/article.html | 11 +++++++++++ modules/wowchemy/layouts/partials/jsonld/event.html | 13 ++++++++++++- modules/wowchemy/layouts/partials/site_head.html | 11 +++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/modules/wowchemy/layouts/partials/jsonld/article.html b/modules/wowchemy/layouts/partials/jsonld/article.html index e3c202af3..cafa6aa5b 100644 --- a/modules/wowchemy/layouts/partials/jsonld/article.html +++ b/modules/wowchemy/layouts/partials/jsonld/article.html @@ -1,6 +1,16 @@ + {{- $page := .page }} {{ $summary := .summary }} +{{/* Search for an image "*featured*" in post folder */}} {{ $featured_image := ($page.Resources.ByType "image").GetMatch "*featured*" }} +{{ $filename := $page.Params.image.filename }} +{{/* Otherwise fall back the image file specified in front matter */}} +{{ if eq $featured_image nil }} + {{/* First search in post folder */}} + {{ $featured_image = ($page.Resources.ByType "image").GetMatch $filename }} + {{/* Otherwise in media/ folder */}} + {{ if eq $featured_image nil}} {{ $featured_image = resources.GetMatch (path.Join "media" $filename) }} {{ end }} +{{end}} {{/* Get schema type. */}} {{ $schema := "Article" }} @@ -45,3 +55,4 @@ "description": {{$summary}} } + \ No newline at end of file diff --git a/modules/wowchemy/layouts/partials/jsonld/event.html b/modules/wowchemy/layouts/partials/jsonld/event.html index a8189451a..0be6a1a4e 100644 --- a/modules/wowchemy/layouts/partials/jsonld/event.html +++ b/modules/wowchemy/layouts/partials/jsonld/event.html @@ -1,6 +1,16 @@ + {{ $page := .page }} {{ $summary := .summary }} -{{ $featured_image := ($page.Resources.ByType "image").GetMatch "*featured*" }} +{{/* Search for an image "*featured*" in post folder */}} +{{ $featured_image := (.Resources.ByType "image").GetMatch "*featured*" }} +{{/* Otherwise fall back the image file specified in front matter */}} +{{ $filename := .Params.image.filename }} +{{ if eq $featured_image nil }} + {{/* First search in post folder */}} + {{ $featured_image = (.Resources.ByType "image").GetMatch $filename }} + {{/* Otherwise in media/ folder */}} + {{ if eq $featured_image nil}} {{ $featured_image = resources.GetMatch (path.Join "media" $filename) }} {{ end }} +{{end}} {{ $author := partial "functions/get_author_name" $page }} + \ No newline at end of file diff --git a/modules/wowchemy/layouts/partials/site_head.html b/modules/wowchemy/layouts/partials/site_head.html index b7e51a0d8..5fad1874c 100644 --- a/modules/wowchemy/layouts/partials/site_head.html +++ b/modules/wowchemy/layouts/partials/site_head.html @@ -1,4 +1,5 @@ {{ $scr := .Scratch }} + @@ -247,7 +248,16 @@ {{/* Get page image for sharing. */}} {{ $sharing_image := resources.GetMatch (path.Join "media" "sharing.*") }} + {{/* Search for an image "*featured*" in post folder */}} {{ $featured_image := (.Resources.ByType "image").GetMatch "*featured*" }} + {{/* Otherwise fall back the image file specified in front matter */}} + {{ $filename := .Params.image.filename }} + {{ if eq $featured_image nil }} + {{/* First search in post folder */}} + {{ $featured_image = (.Resources.ByType "image").GetMatch $filename }} + {{/* Otherwise in media/ folder */}} + {{ if eq $featured_image nil}} {{ $featured_image = resources.GetMatch (path.Join "media" $filename) }} {{ end }} + {{end}} {{ $avatar_image := (.Resources.ByType "image").GetMatch "avatar*" }} {{ $has_logo := fileExists "assets/media/logo.png" | or (fileExists "assets/media/logo.svg") }} {{ $og_image := "" }} @@ -318,3 +328,4 @@ {{ end }} {{ partial "functions/get_hook" (dict "hook" "head-end" "context" .) }} + \ No newline at end of file From 94b2d3cedccb7fd5fe4c60d962f78468b50a5526 Mon Sep 17 00:00:00 2001 From: Agos95 Date: Wed, 24 Aug 2022 16:31:06 +0200 Subject: [PATCH 4/6] update --- modules/wowchemy/layouts/partials/page_header.html | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/wowchemy/layouts/partials/page_header.html b/modules/wowchemy/layouts/partials/page_header.html index 4c2195dd4..1c38be6d0 100644 --- a/modules/wowchemy/layouts/partials/page_header.html +++ b/modules/wowchemy/layouts/partials/page_header.html @@ -3,11 +3,12 @@ {{/* Search for an image "*featured*" in post folder */}} {{ $featured := (.Resources.ByType "image").GetMatch "*featured*" }} {{/* Otherwise fall back the image file specified in front matter */}} +{{ $filename := .Params.image.filename }} {{ if eq $featured nil }} - {{/* First search in post folder */}} - {{ $featured = (.Resources.ByType "image").GetMatch .Params.image.filename }} - {{/* Otherwise in media/ folder */}} - {{ if eq $featured nil}} {{ $featured = resources.GetMatch (path.Join "media" .Params.image.filename) }} {{ end }} + {{/* First search in post folder */}} + {{ $featured = (.Resources.ByType "image").GetMatch $filename }} + {{/* Otherwise in media/ folder */}} + {{ if eq $featured nil}} {{ $featured = resources.GetMatch (path.Join "media" $filename) }} {{ end }} {{end}} {{ $anchor := $page.Params.image.focal_point | default "Smart" }} From 2000e2db6cb279081385c0ecbde6bac5c5aaccb4 Mon Sep 17 00:00:00 2001 From: Agos95 Date: Thu, 25 Aug 2022 11:21:57 +0200 Subject: [PATCH 5/6] use partial function to get featured image --- .../functions/get_featured_image.html | 23 +++++++++++++++++++ .../layouts/partials/jsonld/article.html | 15 ++---------- .../layouts/partials/jsonld/event.html | 15 ++---------- .../layouts/partials/page_header.html | 15 ++---------- .../wowchemy/layouts/partials/site_head.html | 14 ++--------- .../wowchemy/layouts/partials/views/card.html | 11 +-------- .../layouts/partials/views/compact.html | 15 ++---------- .../layouts/partials/views/masonry.html | 11 +-------- .../layouts/partials/views/showcase.html | 13 ++--------- 9 files changed, 37 insertions(+), 95 deletions(-) create mode 100644 modules/wowchemy/layouts/partials/functions/get_featured_image.html diff --git a/modules/wowchemy/layouts/partials/functions/get_featured_image.html b/modules/wowchemy/layouts/partials/functions/get_featured_image.html new file mode 100644 index 000000000..e033221b2 --- /dev/null +++ b/modules/wowchemy/layouts/partials/functions/get_featured_image.html @@ -0,0 +1,23 @@ +{{/* Function to retrieve the featured image */}} +{{/* Inputs: page context */}} +{{/* Output: image resource, or nil if not found */}} + +{{/* + Featured image is searched in this order: + 1. Search for a file `*featured*` in the post directory + 2. Search for a file `.Params.image.filename` in the post directory + 3. Search for a file `.Params.image.filename` in the `assets/media/` directory +*/}} + +{{/* Search for an image "*featured*" in post folder */}} +{{ $resource := (.Resources.ByType "image").GetMatch "*featured*" }} +{{ if eq $resource nil }} + {{/* Otherwise fall back the image file specified in front matter */}} + {{ $filename := .Params.image.filename }} + {{/* Search in post folder */}} + {{ $resource = (.Resources.ByType "image").GetMatch $filename }} + {{/* Otherwise in `assets/media/` folder */}} + {{ if eq $resource nil }} {{ $resource = resources.GetMatch (path.Join "media" $filename) }} {{ end }} +{{ end }} + +{{ return $resource }} \ No newline at end of file diff --git a/modules/wowchemy/layouts/partials/jsonld/article.html b/modules/wowchemy/layouts/partials/jsonld/article.html index cafa6aa5b..507af8ed1 100644 --- a/modules/wowchemy/layouts/partials/jsonld/article.html +++ b/modules/wowchemy/layouts/partials/jsonld/article.html @@ -1,16 +1,6 @@ - {{- $page := .page }} {{ $summary := .summary }} -{{/* Search for an image "*featured*" in post folder */}} -{{ $featured_image := ($page.Resources.ByType "image").GetMatch "*featured*" }} -{{ $filename := $page.Params.image.filename }} -{{/* Otherwise fall back the image file specified in front matter */}} -{{ if eq $featured_image nil }} - {{/* First search in post folder */}} - {{ $featured_image = ($page.Resources.ByType "image").GetMatch $filename }} - {{/* Otherwise in media/ folder */}} - {{ if eq $featured_image nil}} {{ $featured_image = resources.GetMatch (path.Join "media" $filename) }} {{ end }} -{{end}} +{{ $featured_image := partial "functions/get_featured_image.html" $page }} {{/* Get schema type. */}} {{ $schema := "Article" }} @@ -54,5 +44,4 @@ }, "description": {{$summary}} } - - \ No newline at end of file + \ No newline at end of file diff --git a/modules/wowchemy/layouts/partials/jsonld/event.html b/modules/wowchemy/layouts/partials/jsonld/event.html index 0be6a1a4e..9bd35a0f7 100644 --- a/modules/wowchemy/layouts/partials/jsonld/event.html +++ b/modules/wowchemy/layouts/partials/jsonld/event.html @@ -1,16 +1,6 @@ - {{ $page := .page }} {{ $summary := .summary }} -{{/* Search for an image "*featured*" in post folder */}} -{{ $featured_image := (.Resources.ByType "image").GetMatch "*featured*" }} -{{/* Otherwise fall back the image file specified in front matter */}} -{{ $filename := .Params.image.filename }} -{{ if eq $featured_image nil }} - {{/* First search in post folder */}} - {{ $featured_image = (.Resources.ByType "image").GetMatch $filename }} - {{/* Otherwise in media/ folder */}} - {{ if eq $featured_image nil}} {{ $featured_image = resources.GetMatch (path.Join "media" $filename) }} {{ end }} -{{end}} +{{ $featured_image := partial "funcctions/get_featured_image.html" $page }} {{ $author := partial "functions/get_author_name" $page }} - \ No newline at end of file + \ No newline at end of file diff --git a/modules/wowchemy/layouts/partials/page_header.html b/modules/wowchemy/layouts/partials/page_header.html index 1c38be6d0..9c58dfb3f 100644 --- a/modules/wowchemy/layouts/partials/page_header.html +++ b/modules/wowchemy/layouts/partials/page_header.html @@ -1,15 +1,5 @@ - {{ $page := . }} -{{/* Search for an image "*featured*" in post folder */}} -{{ $featured := (.Resources.ByType "image").GetMatch "*featured*" }} -{{/* Otherwise fall back the image file specified in front matter */}} -{{ $filename := .Params.image.filename }} -{{ if eq $featured nil }} - {{/* First search in post folder */}} - {{ $featured = (.Resources.ByType "image").GetMatch $filename }} - {{/* Otherwise in media/ folder */}} - {{ if eq $featured nil}} {{ $featured = resources.GetMatch (path.Join "media" $filename) }} {{ end }} -{{end}} +{{ $featured := partial "functions/get_featured_image.html" $page }} {{ $anchor := $page.Params.image.focal_point | default "Smart" }} @@ -107,5 +97,4 @@

{{ $title }}

{{ partial "page_links_div.html" $page }} {{end}} -{{end}} - \ No newline at end of file +{{end}} \ No newline at end of file diff --git a/modules/wowchemy/layouts/partials/site_head.html b/modules/wowchemy/layouts/partials/site_head.html index 5fad1874c..024e72950 100644 --- a/modules/wowchemy/layouts/partials/site_head.html +++ b/modules/wowchemy/layouts/partials/site_head.html @@ -1,5 +1,4 @@ {{ $scr := .Scratch }} - @@ -249,15 +248,7 @@ {{/* Get page image for sharing. */}} {{ $sharing_image := resources.GetMatch (path.Join "media" "sharing.*") }} {{/* Search for an image "*featured*" in post folder */}} - {{ $featured_image := (.Resources.ByType "image").GetMatch "*featured*" }} - {{/* Otherwise fall back the image file specified in front matter */}} - {{ $filename := .Params.image.filename }} - {{ if eq $featured_image nil }} - {{/* First search in post folder */}} - {{ $featured_image = (.Resources.ByType "image").GetMatch $filename }} - {{/* Otherwise in media/ folder */}} - {{ if eq $featured_image nil}} {{ $featured_image = resources.GetMatch (path.Join "media" $filename) }} {{ end }} - {{end}} + {{ $featured_image := partial "functions/get_featured_image.html" . }} {{ $avatar_image := (.Resources.ByType "image").GetMatch "avatar*" }} {{ $has_logo := fileExists "assets/media/logo.png" | or (fileExists "assets/media/logo.svg") }} {{ $og_image := "" }} @@ -327,5 +318,4 @@ {{ partial "custom_head" . }} {{ end }} {{ partial "functions/get_hook" (dict "hook" "head-end" "context" .) }} - - \ No newline at end of file + \ No newline at end of file diff --git a/modules/wowchemy/layouts/partials/views/card.html b/modules/wowchemy/layouts/partials/views/card.html index fb22e8cea..691acafb5 100644 --- a/modules/wowchemy/layouts/partials/views/card.html +++ b/modules/wowchemy/layouts/partials/views/card.html @@ -41,16 +41,7 @@ {{ partial "page_metadata" (dict "page" $item "is_list" 1) }} {{ end }} - {{/* Search for an image "*featured*" in post folder */}} - {{ $resource := ($item.Resources.ByType "image").GetMatch "*featured*" }} - {{/* Otherwise fall back the image file specified in front matter */}} - {{ $filename := $item.Params.image.filename }} - {{ if eq $resource nil }} - {{/* First search in post folder */}} - {{ $resource = ($item.Resources.ByType "image").GetMatch $filename }} - {{/* Otherwise in media/ folder */}} - {{ if eq $resource nil}} {{ $resource = resources.GetMatch (path.Join "media" $filename) }} {{ end }} - {{ end }} + {{ $resource := partial "functions/get_featured_image.html" $item }} {{ $anchor := $item.Params.image.focal_point | default "Smart" }} {{ with $resource }} {{ $image := .Fill (printf "808x455 webp %s" $anchor) }} diff --git a/modules/wowchemy/layouts/partials/views/compact.html b/modules/wowchemy/layouts/partials/views/compact.html index 7baf44c06..4fc8cf646 100644 --- a/modules/wowchemy/layouts/partials/views/compact.html +++ b/modules/wowchemy/layouts/partials/views/compact.html @@ -1,4 +1,3 @@ - {{ $item := .item }} {{/* Dynamic view adjusts to content type. */}} @@ -75,16 +74,7 @@
- {{/* Search for an image "*featured*" in post folder */}} - {{ $resource := ($item.Resources.ByType "image").GetMatch "*featured*" }} - {{/* Otherwise fall back the image file specified in front matter */}} - {{ $filename := $item.Params.image.filename }} - {{ if eq $resource nil }} - {{/* First search in post folder */}} - {{ $resource = ($item.Resources.ByType "image").GetMatch $filename }} - {{/* Otherwise in media/ folder */}} - {{ if eq $resource nil}} {{ $resource = resources.GetMatch (path.Join "media" $filename) }} {{ end }} - {{ end }} + {{ $resource := partial "functions/get_featured_image.html" $item }} {{ with $resource }} {{ $image := .Resize "150x webp" }} @@ -93,5 +83,4 @@ {{end}}
- - \ No newline at end of file + \ No newline at end of file diff --git a/modules/wowchemy/layouts/partials/views/masonry.html b/modules/wowchemy/layouts/partials/views/masonry.html index da02f4e02..06faa786e 100644 --- a/modules/wowchemy/layouts/partials/views/masonry.html +++ b/modules/wowchemy/layouts/partials/views/masonry.html @@ -18,16 +18,7 @@ {{ $summary = $item.Summary }} {{ end }} -{{/* Search for an image "*featured*" in post folder */}} -{{ $resource := ($item.Resources.ByType "image").GetMatch "*featured*" }} -{{/* Otherwise fall back the image file specified in front matter */}} -{{ $filename := $item.Params.image.filename }} -{{ if eq $resource nil }} - {{/* First search in post folder */}} - {{ $resource = ($item.Resources.ByType "image").GetMatch $filename }} - {{/* Otherwise in media/ folder */}} - {{ if eq $resource nil}} {{ $resource = resources.GetMatch (path.Join "media" $filename) }} {{ end }} -{{ end }} +{{ $resource := partial "functions/get_featured_image.html" $item }}
{{ with $resource }} diff --git a/modules/wowchemy/layouts/partials/views/showcase.html b/modules/wowchemy/layouts/partials/views/showcase.html index b3ad8b117..92534b846 100644 --- a/modules/wowchemy/layouts/partials/views/showcase.html +++ b/modules/wowchemy/layouts/partials/views/showcase.html @@ -49,17 +49,8 @@
- {{/* Search for an image "*featured*" in post folder */}} - {{ $resource := ($item.Resources.ByType "image").GetMatch "*featured*" }} - {{/* Otherwise fall back the image file specified in front matter */}} - {{ $filename := $item.Params.image.filename }} - {{ if eq $resource nil }} - {{/* First search in post folder */}} - {{ $resource = ($item.Resources.ByType "image").GetMatch $filename }} - {{/* Otherwise in media/ folder */}} - {{ if eq $resource nil}} {{ $resource = resources.GetMatch (path.Join "media" $filename) }} {{ end }} - {{ end }} - + {{ $resource := partial "functions/get_featured_image.html" $item }} + {{ with $resource }} {{ $image := .Resize "540x webp" }} {{if $do_link}}{{end}} From 0fcbb849d11ee362e3715cb27886cc4014a02948 Mon Sep 17 00:00:00 2001 From: Agos95 Date: Fri, 26 Aug 2022 08:56:28 +0200 Subject: [PATCH 6/6] add newline at end of file --- .../wowchemy/layouts/partials/functions/get_featured_image.html | 2 +- modules/wowchemy/layouts/partials/jsonld/article.html | 2 +- modules/wowchemy/layouts/partials/jsonld/event.html | 2 +- modules/wowchemy/layouts/partials/page_header.html | 2 +- modules/wowchemy/layouts/partials/site_head.html | 2 +- modules/wowchemy/layouts/partials/views/compact.html | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/wowchemy/layouts/partials/functions/get_featured_image.html b/modules/wowchemy/layouts/partials/functions/get_featured_image.html index e033221b2..03a028534 100644 --- a/modules/wowchemy/layouts/partials/functions/get_featured_image.html +++ b/modules/wowchemy/layouts/partials/functions/get_featured_image.html @@ -20,4 +20,4 @@ {{ if eq $resource nil }} {{ $resource = resources.GetMatch (path.Join "media" $filename) }} {{ end }} {{ end }} -{{ return $resource }} \ No newline at end of file +{{ return $resource }} diff --git a/modules/wowchemy/layouts/partials/jsonld/article.html b/modules/wowchemy/layouts/partials/jsonld/article.html index 507af8ed1..188a0beed 100644 --- a/modules/wowchemy/layouts/partials/jsonld/article.html +++ b/modules/wowchemy/layouts/partials/jsonld/article.html @@ -44,4 +44,4 @@ }, "description": {{$summary}} } - \ No newline at end of file + diff --git a/modules/wowchemy/layouts/partials/jsonld/event.html b/modules/wowchemy/layouts/partials/jsonld/event.html index 9bd35a0f7..e0add5b85 100644 --- a/modules/wowchemy/layouts/partials/jsonld/event.html +++ b/modules/wowchemy/layouts/partials/jsonld/event.html @@ -44,4 +44,4 @@ {{end}} "description": {{$summary}} } - \ No newline at end of file + diff --git a/modules/wowchemy/layouts/partials/page_header.html b/modules/wowchemy/layouts/partials/page_header.html index 9c58dfb3f..b6dd6f174 100644 --- a/modules/wowchemy/layouts/partials/page_header.html +++ b/modules/wowchemy/layouts/partials/page_header.html @@ -97,4 +97,4 @@

{{ $title }}

{{ partial "page_links_div.html" $page }} {{end}}
-{{end}} \ No newline at end of file +{{end}} diff --git a/modules/wowchemy/layouts/partials/site_head.html b/modules/wowchemy/layouts/partials/site_head.html index 024e72950..8d3ac65b7 100644 --- a/modules/wowchemy/layouts/partials/site_head.html +++ b/modules/wowchemy/layouts/partials/site_head.html @@ -318,4 +318,4 @@ {{ partial "custom_head" . }} {{ end }} {{ partial "functions/get_hook" (dict "hook" "head-end" "context" .) }} - \ No newline at end of file + diff --git a/modules/wowchemy/layouts/partials/views/compact.html b/modules/wowchemy/layouts/partials/views/compact.html index 4fc8cf646..55ee4ba9d 100644 --- a/modules/wowchemy/layouts/partials/views/compact.html +++ b/modules/wowchemy/layouts/partials/views/compact.html @@ -83,4 +83,4 @@ {{end}} - \ No newline at end of file +