adds headshot resource support
This commit is contained in:
19
layouts/partials/image.html
Normal file
19
layouts/partials/image.html
Normal file
@ -0,0 +1,19 @@
|
||||
{{ $width := .width }}
|
||||
{{ $height := default $width .height }}
|
||||
{{ $class := .class }}
|
||||
{{ $resource := .resource }}
|
||||
{{ $alt := .alt }}
|
||||
|
||||
{{ with $resource }}
|
||||
{{ $image := .Fit (printf "%dx%d webp" (int $width) (int $height)) }}
|
||||
{{ $fallback := .Fit (printf "%dx%d" (int $width) (int $height)) }}
|
||||
<picture class="{{ $class }} block">
|
||||
<source srcset="{{ $image.RelPermalink }}" type="image/webp">
|
||||
<img
|
||||
src="{{ $fallback.RelPermalink }}"
|
||||
alt="{{ $alt }}"
|
||||
width="{{ $width }}"
|
||||
height="{{ $height }}"
|
||||
loading="lazy">
|
||||
</picture>
|
||||
{{ end }}
|
Reference in New Issue
Block a user