From bf276a6c39934da7c22b5e4fb8afbf6c04b605ff Mon Sep 17 00:00:00 2001 From: serg Date: Sun, 13 Jun 2021 23:35:46 +0300 Subject: add opportunity to set width and height for responsive image Signed-off-by: serg --- layouts/partials/modules/image.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/layouts/partials/modules/image.html b/layouts/partials/modules/image.html index d71c300..48f3c35 100644 --- a/layouts/partials/modules/image.html +++ b/layouts/partials/modules/image.html @@ -4,6 +4,8 @@ image: alt: Description srcset: src/img-1.jpg 500w, src/img-2.jpg 900w sizes: "(min-width: 600px) 50vw, 100vw" + width: crop # get width of image automatically after crop; or define manually a number value for this variable; depends on first (or only one) item in cropSet param + height: crop # get height of image automatically after crop; or define manually a number value for this variable; depends on first (or only one) item in cropSet param cropSet: # order matter; override sibling srcset if defined - options: 1170x500 # first (or only one) item is default cropped image and used as src in tag - options: 900x400 @@ -50,10 +52,14 @@ image: {{$image = partial "funcs/GetImage" (dict "bundle" $imageBundle "path" $src "cmd" .cmd "options" .options)}} {{end}} {{end}} + {{$width := cond (eq .width "crop") $image.Width .width}} + {{$height := cond (eq .height "crop") $image.Height .height}} {{.}} {{if .sources}}{{end}} {{end}} -- cgit v1.2.3