Automatically add image height/width in markdown image tags
This commit is contained in:
parent
ca6ebdce7e
commit
030cd2457e
10
layouts/_default/_markup/render-image.html
Normal file
10
layouts/_default/_markup/render-image.html
Normal 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 -}}
|
Loading…
x
Reference in New Issue
Block a user