From cd957ee5699b7c6d8cfcbad9b64d9d5298e56ccc Mon Sep 17 00:00:00 2001 From: tdro Date: Thu, 15 Dec 2022 22:04:15 -0500 Subject: themes/default/layouts/partials/styles-image-gradient: Extend to gallery --- .../layouts/_default/_markup/render-image.html | 19 ++----------------- themes/default/layouts/partials/gallery-walk.html | 3 +++ .../layouts/partials/styles-image-gradient.html | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 17 deletions(-) create mode 100644 themes/default/layouts/partials/styles-image-gradient.html diff --git a/themes/default/layouts/_default/_markup/render-image.html b/themes/default/layouts/_default/_markup/render-image.html index 9481e9d..3767cb8 100644 --- a/themes/default/layouts/_default/_markup/render-image.html +++ b/themes/default/layouts/_default/_markup/render-image.html @@ -100,23 +100,8 @@ title="{{ $.Text | htmlUnescape }}" width="{{ $width }}" height="{{ $height }}" - {{- printf `style="` | safeHTMLAttr }} - {{- with $colors -}} - background: - {{- range $key, $color := $colors }} - {{- $last := sub (len $colors) 1 -}} - {{- $separator := "," | safeHTMLAttr -}} - {{- $color = $color | safeHTMLAttr -}} - {{- $position := "top" -}} - {{- if eq $last $key -}} - {{- $separator = ";" | safeHTMLAttr -}} - {{- end -}} - {{- if gt $key 0 -}} - {{- $position = "bottom" -}} - {{- end -}} - radial-gradient(ellipse at {{ $position }}, {{ $color }}, transparent){{ $separator }} - {{- end -}} - {{- end -}} + {{ printf `style="` | safeHTMLAttr -}} + {{- partial "styles-image-gradient.html" $colors | safeHTMLAttr -}} {{- printf `"` | safeHTMLAttr }} /> diff --git a/themes/default/layouts/partials/gallery-walk.html b/themes/default/layouts/partials/gallery-walk.html index 72b587c..c17b0da 100644 --- a/themes/default/layouts/partials/gallery-walk.html +++ b/themes/default/layouts/partials/gallery-walk.html @@ -56,6 +56,9 @@ width="{{ $image.Width }}" height="{{ $image.Height }}" src="{{ $image.RelPermalink }}" + {{ printf `style="` | safeHTMLAttr -}} + {{- partial "styles-image-gradient.html" $image.Colors | safeHTMLAttr -}} + {{- printf `"` | safeHTMLAttr }} /> diff --git a/themes/default/layouts/partials/styles-image-gradient.html b/themes/default/layouts/partials/styles-image-gradient.html new file mode 100644 index 0000000..794ea8b --- /dev/null +++ b/themes/default/layouts/partials/styles-image-gradient.html @@ -0,0 +1,18 @@ +{{- $colors := . -}} + +{{- with $colors -}} + background: + {{- range $key, $color := $colors -}} + {{- $last := sub (len $colors) 1 -}} + {{- $separator := "," -}} + {{- $color = $color -}} + {{- $position := "top" -}} + {{- if eq $last $key -}} + {{- $separator = ";" -}} + {{- end -}} + {{- if gt $key 0 -}} + {{- $position = "bottom" -}} + {{- end -}} + radial-gradient(ellipse at {{ $position }}, {{ $color }}, transparent){{ $separator }} + {{- end -}} +{{- end -}} -- cgit v1.2.3