Use custom image render hook to properly size images
This commit is contained in:
parent
91aef9dfc5
commit
22a15f69d5
1 changed files with 17 additions and 0 deletions
17
themes/red/layouts/_default/_markup/render-image.html
Normal file
17
themes/red/layouts/_default/_markup/render-image.html
Normal 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 -}}
|
Loading…
Add table
Reference in a new issue