From f19c61cb9773a29a312e1c7f6eb1cb5ea0fccb09 Mon Sep 17 00:00:00 2001 From: ZhenShuo Leo <98386542+ZhenShuo2021@users.noreply.github.com> Date: Sat, 3 May 2025 16:46:10 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix:=20make=20thumbAndBackground?= =?UTF-8?q?=20behavior=20consistent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add support for URL input, matching the behavior of other hero partials. --- layouts/partials/hero/thumbAndBackground.html | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/layouts/partials/hero/thumbAndBackground.html b/layouts/partials/hero/thumbAndBackground.html index 5f974c4e..036ab514 100644 --- a/layouts/partials/hero/thumbAndBackground.html +++ b/layouts/partials/hero/thumbAndBackground.html @@ -2,7 +2,17 @@ {{- $images := .Resources.ByType "image" -}} {{- $background := $images.GetMatch "*background*" -}} -{{- if not $background }}{{ with .Site.Params.defaultBackgroundImage }}{{ $background = resources.Get . }}{{ end }}{{ end -}} + +{{- if not $background }} + {{ with .Site.Params.defaultBackgroundImage }} + {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} + {{ $background = resources.GetRemote . }} + {{ else }} + {{ $background = resources.Get . }} + {{ end }} + {{ end }} +{{ end -}} + {{- if not $background }}{{ $background = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}} {{- if not $background }}{{ $background = $images.GetMatch "*feature*" }}{{ end -}} {{- $featured := $images.GetMatch "*feature*" -}} @@ -12,7 +22,17 @@ {{- if not $featured }}{{ $featured = resources.GetRemote $url }}{{ end -}} {{ end }} {{- if not $featured }}{{ $featured = $images.GetMatch "*background*" }}{{ end -}} -{{- if not $featured }}{{ with .Site.Params.defaultBackgroundImage }}{{ $featured = resources.Get . }}{{ end }}{{ end -}} + +{{- if not $featured }} + {{ with .Site.Params.defaultFeaturedImage }} + {{ if or (strings.HasPrefix . "http:") (strings.HasPrefix . "https:") }} + {{ $featured = resources.GetRemote . }} + {{ else }} + {{ $featured = resources.Get . }} + {{ end }} + {{ end }} +{{ end -}} + {{ $isParentList := eq (.Scratch.Get "scope") "list" }} {{ $shouldBlur := $.Params.layoutBackgroundBlur | default (or (and ($.Site.Params.article.layoutBackgroundBlur | default true) (not $isParentList))