Is it possible to define default page resources in config

I currently use a if-else-construction to use a default image as header image if there is no image defined as resource in the content file. Is it somehow possible to apply image processing on this default image, too?

Here is a code snippet to show what I do now:

{ if .Resources.GetMatch "feature" }}
		{{ $preview := .Resources.GetMatch "feature" }}
		{{ with $preview }}
		{{ $scaled := .Fill "1920x1040 Gaussian Center" }}
		<div class="vh-100 dt w-100 tc bg-dark-gray white cover" style="background: linear-gradient( rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5) ), url({{ $scaled.Permalink }}) no-repeat center;">
		{{ end }}
	{{ else }}
		<div class="vh-100 dt w-100 tc bg-dark-gray white cover" style="background: linear-gradient( rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5) ), url(/images/cover.jpg) no-repeat center;">
	{{ end }}

As you see I just insert the default image without processing.

Is it possible to define a default resource in config which could be inserted by something like this:

.Site.Resources.GetMatch "feature"

TIA
juh

You need to put “site wide” resources below /assets somewhere and load them via resources.Get, resources.GetMatch or resources.Match.

1 Like

For completenes, I can add that one other way of doing the above is to put common resources in a “headless bundle” and do .Site.GetPage "mybundle" and then do ´.Resources.GetMatch…` on that bundle.

1 Like