{{ $filename := .Get "filename" -}}
{{ $ext := substr $filename (sub (len $filename) 4) }}
<p
{{ if eq (.Get "align") "left" }}class="leftimg"{{else if (.Get "align") "right"}}class="rightimg"{{end }}>
{{ if eq $ext ".mp4" }}
<video src="/media/
{{- with .Get "width"}}{{.}}{{else}}100{{end}}x{{with .Get "height"}}{{.}}{{else}}{{end}}/{{ $filename -}}"
controls allowfullscreen
></video>
{{ else }}
<a href="/media/{{ $filename }}" target="_blank"><img src="/media/
{{- with .Get "width"}}{{.}}{{else}}100{{end}}x{{with .Get "height"}}{{.}}{{else}}{{end}}/{{ $filename -}}"
{{ with .Get "caption" }}title="{{.}}"{{end}}
{{ with .Get "caption" }}alt="{{.}}"{{end}}
/></a>
{{end}}
</p>
