amethyst/layouts/_default/_markup/render-image.html
2023-01-01 23:41:14 +00:00

10 lines
527 B
HTML

{{$src := .Destination | safeURL }}
{{$width := index (split .Text "|") 1 | default "auto" }}
{{$external := strings.HasPrefix $src "http" }}
{{- if $external -}}
<img src="{{ $src }}" width="{{ $width }}" alt="{{ .Text }}" {{ with .Title }} title="{{ . }}" {{ end }} />
{{- else -}}
{{$fixedUrl := (cond (hasPrefix $src "/") $src (printf "%s%s" .Page.File.Dir $src)) | urlize}}
<img src="{{.Page.Site.BaseURL}}{{ $fixedUrl }}" width="{{ $width }}" alt="{{ .Text }}" {{ with .Title }}
title="{{ . }}" {{ end }} />
{{- end -}}