Automatically add image height/width in markdown image tags

This commit is contained in:
quest 2022-09-12 19:37:08 -10:00
parent ca6ebdce7e
commit 030cd2457e
No known key found for this signature in database
GPG Key ID: E49B7E0000228DDD

View File

@ -0,0 +1,10 @@
{{- $img := .Page.Resources.GetMatch .Destination -}}
{{- if and (not $img) .Page.File -}}
{{- $path := path.Join .Page.File.Dir .Destination -}}
{{- $img = resources.Get $path -}}
{{- end -}}
{{- with $img -}}
<img alt="{{ $.Text }}" src="{{ $img.RelPermalink }}" width={{ $img.Width }} height={{ $img.Height }} />
{{- else -}}
<img alt="{{ $.Text }}" src="{{ $.Destination | safeURL }}" />
{{- end -}}