diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html index 9441c0cb9..31cfa0542 100644 --- a/layouts/_default/_markup/render-image.html +++ b/layouts/_default/_markup/render-image.html @@ -1,13 +1,13 @@ {{- $lightgallery := .Page.Params.lightgallery | default site.Params.Page.lightgallery | default false -}} {{- if .Title -}} {{- else -}} {{- end -}} diff --git a/layouts/_default/summary.html b/layouts/_default/summary.html index 617094b12..00ea78dff 100644 --- a/layouts/_default/summary.html +++ b/layouts/_default/summary.html @@ -6,7 +6,12 @@ {{- with $image -}}
{{- end -}} diff --git a/layouts/partials/function/imageHandler.html b/layouts/partials/function/imageHandler.html deleted file mode 100644 index b27d60e3f..000000000 --- a/layouts/partials/function/imageHandler.html +++ /dev/null @@ -1,18 +0,0 @@ -{{- $return := 0 -}} -{{- $suffixList := slice ".jpeg" ".jpg" ".png" ".gif" ".bmp" ".tif" ".tiff" ".webp" -}} - -{{- if not (eq .Optim true) -}} - {{- $return = dict "S" .Image "M" .Image "L" .Image "Optimized" false -}} -{{- else if or - (not (eq site.Params.optimizeImages true)) - (not (dict "Path" .Image.RelPermalink "Suffixes" $suffixList | partial "function/suffixValidation.html")) - -}} - {{- $return = dict "S" .Image "M" .Image "L" .Image "Optimized" true -}} -{{- else -}} - {{- $s := .Image.Resize (site.Params.srcsetSmallResizeMethod | default "700x webp Lanczos q60") -}} - {{- $m := .Image.Resize (site.Params.srcsetDefaultResizeMethod | default "1200x webp Lanczos q60") -}} - {{- $l := .Image.Resize (site.Params.srcsetLargeResizeMethod | default "2000x webp Lanczos q60") -}} - {{- $return = dict "S" $s "M" $m "L" $l "Optimized" true -}} -{{- end -}} - -{{- return $return -}} diff --git a/layouts/partials/plugin/image.html b/layouts/partials/plugin/image.html index 4608828b6..bf21926fe 100644 --- a/layouts/partials/plugin/image.html +++ b/layouts/partials/plugin/image.html @@ -13,7 +13,12 @@ {{- $resource := (.Resources.Get .Src) | default (resources.Get .Src) | default nil -}} {{- $cacheRemote := true -}} - +{{/* {{- $optim := slice + (dict "Process" "fill 800x240 Center webp q75" "descriptor" "800w") + (dict "Process" "fill 1200x360 Center webp q75" "descriptor" "1200w") + (dict "Process" "fill 1600x480 Center webp q75" "descriptor" "1600w") +-}} */}} +{{- $optim := .Optim -}} {{- if not $resource | and (partial "function/isUrlRemote.html" (urls.Parse .Src)) | and $cacheRemote -}} {{- with $remoteResource := resources.GetRemote .Src -}} {{- with .Err -}} @@ -26,7 +31,27 @@ {{- end -}} {{- end -}} -{{- with $resource -}} +{{- $srcset := "" -}} +{{- if $optim | and $resource -}} + {{ $srcsetSlice := slice -}} + {{- range $optim -}} + {{- if .Process -}} + {{- $processed := $resource.Process .Process -}} + {{- $srcsetSlice = $srcsetSlice | append (printf "%s %s" $processed.RelPermalink .descriptor) -}} + {{- end -}} + {{- end -}} + {{- $srcset = delimit $srcsetSlice ", " -}} +{{- end -}} + +{{- $src := $resource.RelPermalink | default .Src -}} +{{- $alt := .Alt | default .Title | default "alt text" -}} +{{- $height := .Height | default $resource.Height | default "" -}} +{{- $width := .Width | default $resource.Width | default "" -}} + + + + +{{/* {{- with $resource -}}{{- $resource -}} @@ -44,17 +69,10 @@
This resource is not a page resource nor a global resources
{{- .Src -}} -{{- end -}} - -{{- $optim := slice - (dict "Resize" "800x webp Lanczos q75" "descriptor" "") - (dict "Resize" "1200x webp Lanczos q75" "descriptor" "1.5x") - (dict "Resize" "1600x webp Lanczos q75" "descriptor" "2x") --}} - - +{{- end -}} */}} -{{/* {{- $remote := .Remote | default false -}} +{{/* +{{- $remote := .Remote | default false -}} {{- $optimize := .Optim | default false -}} {{- $optimized := false -}} diff --git a/layouts/posts/single.html b/layouts/posts/single.html index cc45c2813..62458d274 100644 --- a/layouts/posts/single.html +++ b/layouts/posts/single.html @@ -151,7 +151,12 @@