{{ $images := $.Resources.ByType "image" -}}
{{ $custom_file := .Params.feature_image }}
{{ $custom_image := $images.GetMatch $custom_file }}
{{ $feature_image := $images.GetMatch "*feature*" -}}
{{ $img_src := "" }}
{{ with $custom_image }}
  {{ $img_src = .RelPermalink }}
{{ else }}
  {{ with $feature_image }}
    {{ $img_src = .RelPermalink }}
  {{ end }}
{{ end }}
{{ if $img_src }}
<img class="feature-image" 
     srcset="{{ $img_src }} 480w, {{ $img_src }} 800w"
     sizes="(max-width: 600px) 480px, 800px"
     src="{{ $img_src }}"
     {{ with $.Params.feature_image_alt }}alt="{{ . }}"{{ else }}alt="Feature image"{{ end }}>
{{ end }}