{{ $img := .Page.Resources.GetMatch (printf "*%s*" (.Get "src")) }}
{{ $width := .Get "width" }}
{{ $rimg := $img.Resize (print (default "640x" $width) " jpeg picture") }}
{{ $title := .Get "title" }}
<a href="{{ $img.RelPermalink }}"><img src="{{ $rimg.RelPermalink }}" width="{{ $rimg.Width }}" height="{{ $rimg.Height }}"{{ if $title }} alt="{{ $title }}"{{ end }}></a>