EdikoyoWiki/layouts/_default/_markup/render-image.html
2024-09-07 08:52:05 +00:00

20 lines
668 B
HTML

{{- $url := urls.Parse .Destination -}}
{{- $scheme := $url.Scheme -}}
<img src="
{{- if eq $scheme "" -}}
{{- $cleanedPath := strings.Replace $url.Path "\\" "/" -1 -}}
{{- if strings.HasSuffix $cleanedPath ".md" -}}
{{- relref .Page $cleanedPath | safeURL -}}
{{- else -}}
{{- printf "/%s%s" .Page.File.Dir $cleanedPath | safeURL -}}
{{- end -}}
{{- else -}}
{{- .Destination | safeURL -}}
{{- end -}}"
{{- with .Title }} title="{{ . | safeHTML }}"{{- end -}}
{{- with .Text }} alt="{{ . | safeHTML }}"
{{- end -}}
/>
{{- /* whitespace stripped here to avoid trailing newline in rendered result caused by file EOL */ -}}