{{ $img := $.Page.Resources.GetMatch (.Get "src")}}
<figure {{ with .Get "class" }} class="{{ . }}"{{ end }}>
	{{ with .Get "link" }}
		<a href="{{ . | absURL }}">
	{{ end }}
	<img src="{{ $img.RelPermalink }}"
	{{ with .Get "alt"}} alt="{{ . }}"{{ end }}
	{{ with .Get "title"}} title="{{ . }}"{{ end }}
	{{ with .Get "height"}} height="{{ . }}"{{ end }}
	{{ with .Get "width"}} width="{{ . }}"{{ end }} />
	{{ with .Get "link" }}
		</a>
	{{ end }}
	{{ if .Get "caption" }}
	<figcaption>
		<p>{{ .Get "caption" }}
		{{ if .Get "attr" }}
			<span class="attribution">
			{{ with .Get "attrlink" }}
				<a href="{{ . }}">
			{{ end }}
			{{ .Get "attr" }}
			{{ with .Get "attrlink" }}
				</a>
			{{ end }}
			</span>
		{{ end }}
		</p>
	</figcaption>
	{{ end }}
</figure>