From ad433679f34ff636f07026d42b21ffeb3dd54e97 Mon Sep 17 00:00:00 2001
From: Patrick Kollitsch <83281+davidsneighbour@users.noreply.github.com>
Date: Sun, 17 May 2026 07:33:35 +0000
Subject: [PATCH] fix: support images array for featured image (#967)
---
layouts/_partials/func/GetFeaturedImage.html | 28 ++++++++++++++++++++++------
1 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/layouts/_partials/func/GetFeaturedImage.html b/layouts/_partials/func/GetFeaturedImage.html
index 9684d7f..f9f0804 100644
--- a/layouts/_partials/func/GetFeaturedImage.html
+++ b/layouts/_partials/func/GetFeaturedImage.html
@@ -5,11 +5,14 @@
If a featured_image was set in the page's front matter, then that will be used.
+ If no featured_image was set, this will use the first image from the page's
+ images front matter array.
+
If not set, this will search page resources to find an image that contains the word
"cover", and if found, returns the path to that resource.
- If no featured_image was set, and there's no "cover" image in page resources, then
- this partial returns an empty string (which evaluates to false).
+ If no featured_image or images value was set, and there's no "cover" image in page
+ resources, then this partial returns an empty string (which evaluates to false).
@return RelPermalink to featured image, or an empty string if not found.
@@ -27,11 +30,24 @@
{{ with $.Resources.GetMatch . }}
{{ $linkToCover = .RelPermalink }}
{{ end }}
-{{/* Find the first image with 'cover' in the name in this page bundle. */}}
{{ else }}
- {{ with .Resources.ByType "image" }}
- {{ with .GetMatch (fmt.Printf "**{%s}*" $matches) }}
- {{ $linkToCover = .RelPermalink }}
+ {{/* Use the first value from the images front matter array if present. */}}
+ {{ with .Params.images }}
+ {{ range first 1 . }}
+ {{ with . }}
+ {{ $linkToCover = strings.Trim . "/" | urls.AbsURL }}
+ {{/* If we find a Page Resource matching the exact value, we use it instead. */}}
+ {{ with $.Resources.GetMatch . }}
+ {{ $linkToCover = .RelPermalink }}
+ {{ end }}
+ {{ end }}
+ {{ end }}
+ {{/* Find the first image with 'cover' in the name in this page bundle. */}}
+ {{ else }}
+ {{ with .Resources.ByType "image" }}
+ {{ with .GetMatch (fmt.Printf "**{%s}*" $matches) }}
+ {{ $linkToCover = .RelPermalink }}
+ {{ end }}
{{ end }}
{{ end }}
{{ end }}
--
Gitblit v1.10.0