mirror of
https://github.com/gohugoio/hugo.git
synced 2025-09-02 22:52:51 +02:00
Merge commit 'b3d87dd0fd746f07f9afa6e6a2969aea41da6a38'
This commit is contained in:
27
docs/layouts/_partials/helpers/picture.html
Normal file
27
docs/layouts/_partials/helpers/picture.html
Normal file
@@ -0,0 +1,27 @@
|
||||
{{ $image := .image }}
|
||||
{{ $width := .width | default 1000 }}
|
||||
{{ $width1x := div $width 2 }}
|
||||
{{ $imageWebp := $image.Resize (printf "%dx webp" $width) }}
|
||||
{{ $image1x := $image.Resize (printf "%dx" $width1x) }}
|
||||
{{ $image1xWebp := $image.Resize (printf "%dx webp" $width1x) }}
|
||||
{{ $class := .class | default "h-64 tablet:h-96 lg:h-full w-full object-cover lg:absolute" }}
|
||||
{{ $loading := .loading | default "eager" }}
|
||||
<picture>
|
||||
<source
|
||||
srcset="{{ $imageWebp.RelPermalink }}"
|
||||
type="image/webp"
|
||||
media="(min-width: 1200px)">
|
||||
<source
|
||||
srcset="{{ $image.RelPermalink }}"
|
||||
type="image/jpeg"
|
||||
media="(min-width: 1200px)">
|
||||
<source srcset="{{ $image1xWebp.RelPermalink }}" type="image/webp">
|
||||
<source srcset="{{ $image1x.RelPermalink }}" type="image/jpeg">
|
||||
<img
|
||||
class="{{ $class }}"
|
||||
src="{{ $image1x.RelPermalink }}"
|
||||
alt=""
|
||||
loading="{{ $loading }}"
|
||||
width="{{ $image1x.Width }}"
|
||||
height="{{ $image1x.Height }}">
|
||||
</picture>
|
Reference in New Issue
Block a user