birdsounds.media/layouts/partials/photo_asset.html
a 9aa43df629 First commit
The basic parts of the layouts/theme should work. I have only populated 2 albums so far.
2024-05-17 21:14:05 -05:00

29 lines
No EOL
863 B
HTML

{{ $alt := or .Params.alt .Title "image" }}
{{ with resources.GetMatch .Params.photo_asset }}
{{/*
1280px (80rem) = 640,
1600px (100rem) = 960,
1920px (120rem) = 1280
*/}}
{{ $smallw := default "640x webp Lanczos" }}
{{ $mediumw := default "960x webp Lanczos" }}
{{ $largew := default "1280x webp Lanczos" }}
{{ $.Scratch.Set "small" (.Resize $smallw) }}
{{ $.Scratch.Set "medium" (.Resize $mediumw) }}
{{ $.Scratch.Set "large" (.Resize $largew) }}
{{ $small := $.Scratch.Get "small" }}
{{ $medium := $.Scratch.Get "medium" }}
{{ $large := $.Scratch.Get "large" }}
<picture>
<source media="(max-width: 80rem)" srcset="{{ $small.Permalink }}" />
<source media="(max-width: 100rem)" srcset="{{ $medium.Permalink }}" />
<img src="{{ $large.Permalink }}" alt="{{ $alt }}" title="{{ $alt }}">
</picture>
{{ end }} {{/* with asset */}}