22
layouts/partials/image/reflect.html
Normal file
22
layouts/partials/image/reflect.html
Normal file
@@ -0,0 +1,22 @@
|
||||
{{- $input := . -}}
|
||||
|
||||
{{- $src := $input -}}
|
||||
{{- $title := "" -}}
|
||||
{{- $alt := "" -}}
|
||||
|
||||
{{- if reflect.IsMap $input -}}
|
||||
{{- $src = $input.src | default $input.path | default "" -}}
|
||||
{{- $title = $input.title | default $input.caption | default "" -}}
|
||||
{{- $alt = $input.alt | default $title -}}
|
||||
{{- end -}}
|
||||
|
||||
{{ $result := dict "image" nil "title" $title "alt" $alt }}
|
||||
|
||||
{{- if $src -}}
|
||||
{{- $isRemote := strings.HasPrefix $src "http" -}}
|
||||
{{- $image := cond $isRemote (resources.GetRemote $src) (resources.Get $src) -}}
|
||||
|
||||
{{- $result = (dict "image" $image "title" $title "alt" $alt) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- return $result -}}
|
Reference in New Issue
Block a user