ar.falsy.cat/layouts/_default/_markup/render-image.html

10 lines
507 B
HTML
Raw Normal View History

2022-02-16 04:03:02 +00:00
{{$src := .Destination | safeURL }}
{{$width := index (split .Text "|") 1 | default "auto" }}
2022-02-16 04:03:02 +00:00
{{$external := strings.HasPrefix $src "http" }}
{{- if $external -}}
<img src="{{ $src }}" width="{{ $width }}" alt="{{ .Text }}" {{ with .Title }} title="{{ . }}" {{ end }} />
2022-02-16 04:03:02 +00:00
{{- else -}}
{{$fixedUrl := (cond (hasPrefix $src "/") $src (print "/" $src)) | urlize}}
<img src="{{.Page.Site.BaseURL}}{{ $fixedUrl }}" width="{{ $width }}" alt="{{ .Text }}" {{ with .Title }} title="{{ . }}" {{ end }} />
2022-02-16 04:03:02 +00:00
{{- end -}}