You should be coding defensively.
A simplified example (ignores alt
and title
attributes):
{{ $r := "" }}
{{ with .Page.Resources.Get .Destination }}
{{ $r = . }}
{{ else }}
{{ errorf "The image render hook was unable to get image %q." .Destination }}
{{ end }}
{{ with $r }}
{{ with .Fill "400x200 webp q50" }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ end }}
{{ end }}
If the image isn’t present, processing stops, and you will never get to the image processing bits.