{{ $src := .Page.Resources.GetMatch (printf "*%s*" (.Get "src")) }}
{{ $thumb := $src.Fill "500x500" }}
<div class="box">
<figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<div class="img"{{ if .Parent }} style="background-image: url('{{ $thumb.RelPermalink }}');"{{ end }}>
<img itemprop="thumbnail" src="{{ $thumb.RelPermalink }}" {{ with .Get "caption" }}alt="{{.}}"{{ end }}/>
</div>
<a href="{{ $src.RelPermalink }}" itemprop="contentUrl" data-size="{{ $src.Width }}x{{ $src.Height }}"></a>
{{ with .Get "caption" }}
<figcaption><p>{{ . }}</p></figcaption>
{{ end }}
</figure>