birdsounds.media/layouts/partials/photo_asset.html

29 lines
863 B
HTML
Raw Permalink Normal View History

{{ $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 */}}