aboutsummaryrefslogtreecommitdiff
path: root/site/layouts
diff options
context:
space:
mode:
authorXhmikosR <[email protected]>2024-04-01 21:48:31 +0300
committerGitHub <[email protected]>2024-04-01 21:48:31 +0300
commit2ba7dae3c080c5fac21f4d7f1663c8f524fefb26 (patch)
tree50f385c2f03112688c0cb47830897f9bdd28c402 /site/layouts
parent24cc552343c817b0d13201639c635a778d55da09 (diff)
downloadbootstrap-2ba7dae3c080c5fac21f4d7f1663c8f524fefb26.tar.xz
bootstrap-2ba7dae3c080c5fac21f4d7f1663c8f524fefb26.zip
Add a render image hook (#39768)
Images are now lazyloaded, they have width and height attributes and the classes are centralized. Only applies to Markdown images
Diffstat (limited to 'site/layouts')
-rw-r--r--site/layouts/_default/_markup/render-image.html8
1 files changed, 8 insertions, 0 deletions
diff --git a/site/layouts/_default/_markup/render-image.html b/site/layouts/_default/_markup/render-image.html
new file mode 100644
index 000000000..fd089f7be
--- /dev/null
+++ b/site/layouts/_default/_markup/render-image.html
@@ -0,0 +1,8 @@
+{{- $originalSrc := .Destination | safeURL -}}
+{{- $localImgPath := path.Join "/site/static/docs" site.Params.docs_version $originalSrc -}}
+{{- /* This shouldn't be needed but we have a weird folder structure with version included... */ -}}
+{{- $src := urls.JoinPath "/docs" site.Params.docs_version $originalSrc -}}
+{{- $config := imageConfig $localImgPath -}}
+{{- $classes := "d-block img-fluid" -}}
+
+<img src="{{ $src }}" class="{{ $classes }}" alt="{{ .Text }}" width="{{ $config.Width }}" height="{{ $config.Height }}" loading="lazy">