32 lines
890 B
HTML
32 lines
890 B
HTML
{{- $input := . -}}
|
|
|
|
{{- $src := $input -}}
|
|
{{- $caption := "" -}}
|
|
{{- $title := "" -}}
|
|
{{- $alt := "" -}}
|
|
|
|
{{- if reflect.IsMap $input -}}
|
|
{{- $src = $input.src | default "" -}}
|
|
{{- $caption = $input.caption | default "" -}}
|
|
{{- $title = $input.title | default $caption | default "" -}}
|
|
{{- $alt = $input.alt | default $title | default "" -}}
|
|
{{- end -}}
|
|
|
|
{{ $result := dict "image" nil "caption" $caption "title" $title "alt" $alt }}
|
|
|
|
{{- if $src -}}
|
|
{{- $isRemote := strings.HasPrefix $src "http" -}}
|
|
{{- $image := "" -}}
|
|
|
|
{{- if $isRemote -}}
|
|
{{- $remote := resources.GetRemote $src -}}
|
|
{{- $image = resources.Copy (printf "static/3rd-party/%s" $remote.Name) $remote -}}
|
|
{{- else -}}
|
|
{{- $image = resources.Get $src -}}
|
|
{{- end -}}
|
|
|
|
{{- $result = (dict "image" $image "caption" $caption "title" $title "alt" $alt) -}}
|
|
{{- end -}}
|
|
|
|
{{- return $result -}}
|