Hello whiny.lol
This commit is contained in:
27
layouts/_markup/render-image.html
Normal file
27
layouts/_markup/render-image.html
Normal file
@@ -0,0 +1,27 @@
|
||||
{{- $alt := .Text -}}
|
||||
{{- $caption := .Title -}}
|
||||
{{- $src := .Destination -}}
|
||||
|
||||
{{- $image := .Page.Resources.GetMatch $src -}}
|
||||
|
||||
{{- if $image -}}
|
||||
{{- $webp := $image.Resize (printf "%dx%d webp" $image.Width $image.Height) -}}
|
||||
|
||||
{{- if $caption -}}
|
||||
<figure>
|
||||
<img src="{{ $webp.RelPermalink }}" alt="{{ $alt }}" width="{{ $webp.Width }}" height="{{ $webp.Height }}">
|
||||
<figcaption>{{ $caption }}</figcaption>
|
||||
</figure>
|
||||
{{- else -}}
|
||||
<img src="{{ $webp.RelPermalink }}" alt="{{ $alt }}" width="{{ $webp.Width }}" height="{{ $webp.Height }}">
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- if $caption -}}
|
||||
<figure>
|
||||
<img src="{{ $src }}" alt="{{ $alt }}">
|
||||
<figcaption>{{ $caption }}</figcaption>
|
||||
</figure>
|
||||
{{- else -}}
|
||||
<img src="{{ $src }}" alt="{{ $alt }}">
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
Reference in New Issue
Block a user