<span{{ with .Get "class" }} class="{{ . }}"{{ else }} class="image-container"{{ end }}>
    {{- $src := .Get "src" -}}
    {{- $link := .Get "link" -}}
    {{- $target := .Get "target" -}}
    {{- $alt := .Get "alt" -}}
    {{- $caption := .Get "caption" -}}
    {{- $title := .Get "title" -}}
    {{- $attr := .Get "attr" -}}
    {{- $attrlink := .Get "attrlink" -}}
    {{- if not $link -}}{{- $link = $src -}}{{- end -}}
    {{- if not $target -}}{{- $target = "_blank" -}}{{- end -}}
    <span class="link" ><a href="{{ $link }}" 
        target="{{ $target }}"{{ with .Get "rel" }} 
        rel="{{ . }}"{{ end }}><img class="img" src="{{ $src }}" 
         {{- if or $alt $caption }} 
         alt="{{ with $alt }}{{ . }}{{ else }}{{ $caption | markdownify| plainify }}{{ end }}"
         {{- end -}}
         {{- with .Get "width" }} width="{{ . }}"{{ end -}}
         {{- with .Get "height" }} height="{{ . }}"{{ end -}}
    /></a></span>
    {{- if or (or $title $caption) $attr -}}
        <span class="caption">
            {{ with $title -}}
                <span class="title">{{ . }}</span class="image-container-caption">
            {{- end -}}
            {{- if or $caption $attr -}}<p>
                {{- $caption | markdownify -}}
                {{- with $attrlink }}
                    <a href="{{ . }}">
                {{- end -}}
                {{- $attr | markdownify -}}
                {{- if $attrlink }}</a>{{ end }}</p>
            {{- end }}
        </span>
    {{- end }}
</span>