Use custom image render hook to properly size images

This commit is contained in:
Joshua Goins 2022-09-26 11:06:31 -04:00
parent 91aef9dfc5
commit 22a15f69d5

View file

@ -0,0 +1,17 @@
{{- $url := .Destination | safeURL -}}
{{- $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 -}}
<figure>
<a href="{{ $img.RelPermalink }}" data-download="true">
<img class="article-img" width="{{ $img.Width }}" height="{{ $img.Height}}" src="{{ $img.RelPermalink }}" alt="{{ $.Text }}" />
</a>
<figcaption>{{ $.Text }}</figcaption>
</figure>
{{- end -}}