diff options
| author | Bobby <[email protected]> | 2024-08-16 20:47:33 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-08-16 20:47:33 -0400 |
| commit | 6b28433d9cfde435be8ec2bd6cf91e6324d08865 (patch) | |
| tree | 8343c27b8b95ff5639233e81cf157f92e5688466 /site/layouts/partials/responsive-img.html | |
| parent | d53094ec16ba385faae2973ddee648698b32ab24 (diff) | |
| parent | 048f56f51460df75e92a2f7b472e1c56baeb68f7 (diff) | |
| download | bootstrap-6b28433d9cfde435be8ec2bd6cf91e6324d08865.tar.xz bootstrap-6b28433d9cfde435be8ec2bd6cf91e6324d08865.zip | |
Diffstat (limited to 'site/layouts/partials/responsive-img.html')
| -rw-r--r-- | site/layouts/partials/responsive-img.html | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/site/layouts/partials/responsive-img.html b/site/layouts/partials/responsive-img.html new file mode 100644 index 000000000..06aafb6aa --- /dev/null +++ b/site/layouts/partials/responsive-img.html @@ -0,0 +1,22 @@ +{{- /* + Accepts context, classes, imgPath, alt and lazyload +*/ -}} + +{{- $lazy := .lazyload | default true -}} +{{- $classes := slice "img-fluid" "mx-auto" | append (slice .classes) -}} + +{{- $basePath := path.Join "/docs" .context.Site.Params.docs_version (path.Dir .imgPath) -}} +{{- $basename := path.BaseName .imgPath -}} +{{- $ext := path.Ext .imgPath -}} +{{- $imgPath := path.Join $basePath (printf "%s%s" $basename $ext) -}} +{{- $imgPath2x := path.Join $basePath (printf "%s@2x%s" $basename $ext) -}} + +{{- with (imageConfig (path.Join "/site/static" $imgPath)) }} +<img class="{{ delimit $classes " " }}" + srcset="{{ $imgPath }}, {{ $imgPath2x }} 2x" + src="{{ $imgPath }}" + alt="{{ $.alt }}"{{ if eq $lazy true }} + loading="lazy"{{ end }} + width="{{ .Width }}" + height="{{ .Height }}"> +{{- end }} |
