Set a fall-back image

I found the code below in this forum. I would like to set a fall-back image in the assets folder for those page bundles without the cover.jpg image. How to do that?

{{- with .Resources.Get "cover.jpg"}}
  {{- with .Fill "300x192 webp "}}
     <img src="{{ .Permalink }}" alt="{{ .Title }}" width="{{ .Width }}" height="{{ .Height }}" loading="lazy"/>
 {{- end }}
{{- end }}
{{- with or (.Resources.Get "cover.jpg") (resources.Get "fallback.jpg") }}
  {{- with .Fill "300x192 webp" }}
    <img src="{{ .Permalink }}" alt="{{ .Title }}" width="{{ .Width }}" height="{{ .Height }}" loading="lazy"/>
  {{- end }}
{{- end }}
1 Like

Thank you!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.