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 -}}
- {{- dict "Src" .Destination "Title" .Text "Caption" .Title "Linked" $lightgallery "Resources" .Page.Resources "Optim" true "Remote" true | partial "plugin/image.html" -}} + {{- dict "Src" .Destination "Title" .Text "Caption" .Title "Linked" $lightgallery "Resources" .Page.Resources | partial "plugin/image.html" -}}
{{- .Title | safeHTML -}}
{{- else -}}
- {{- dict "Src" .Destination "Title" .Text "Linked" $lightgallery "Resources" .Page.Resources "Optim" true "Remote" true | partial "plugin/image.html" -}} + {{- dict "Src" .Destination "Title" .Text "Linked" $lightgallery "Resources" .Page.Resources | partial "plugin/image.html" -}}
{{- 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 @@

{{ . }}

{{- $image := $params.featuredimage -}} {{- with $image -}} {{- end -}} {{- /* Series list */ -}} diff --git a/layouts/shortcodes/image.html b/layouts/shortcodes/image.html index 8e23075c7..4bb365af6 100644 --- a/layouts/shortcodes/image.html +++ b/layouts/shortcodes/image.html @@ -11,8 +11,6 @@ {{- $options = dict "Width" (.Get "width") | merge $options -}} {{- $options = .Get "linked" | ne false | dict "Linked" | merge $options -}} {{- $options = dict "Rel" (.Get "rel") | merge $options -}} - {{- $options = dict "Optim" true | merge $options -}} - {{- $options = dict "Remote" true | merge $options -}} {{- else -}} {{- $options = cond $caption true false | dict "Linked" | merge $options -}} {{- end -}}