{{- $url := .Destination | safeURL -}}
{{- $block := gt (len .Title) 0 -}}

{{- if $block -}}
<span class="image-container"><span class="link">
{{- end -}}
<img {{ if $block }}class="img"{{ end }} src="{{- $url -}}"
        alt{{- with .Text -}}="{{- . -}}" {{- end -}} />
{{- if $block -}}
</span>
  {{- if ne .Title " " -}}
    <span class="caption"><span class="title">{{- .Title | safeHTML -}}</span></span>
  {{- end -}}
</span>
{{- end -}}