diff options
| author | tdro <tdro@noreply.example.com> | 2022-06-11 23:15:33 -0400 |
|---|---|---|
| committer | tdro <tdro@noreply.example.com> | 2022-06-11 23:15:33 -0400 |
| commit | ea9c7faaaa82401bc8e32efd40c353a2696ac0b9 (patch) | |
| tree | db17f9cd7d6b720d3ea86a2afd76a6253de307e4 | |
| parent | ed5ac80fac302574d5643bf6f69066805d520075 (diff) | |
| download | canory-ea9c7faaaa82401bc8e32efd40c353a2696ac0b9.tar.gz canory-ea9c7faaaa82401bc8e32efd40c353a2696ac0b9.tar.bz2 canory-ea9c7faaaa82401bc8e32efd40c353a2696ac0b9.zip | |
themes/default/layouts: Try fit instead of resize
Default to webp, and use fit method. Might produce better image
rendering overall.
5 files changed, 24 insertions, 25 deletions
diff --git a/themes/default/layouts/_default/_markup/render-image.html b/themes/default/layouts/_default/_markup/render-image.html index ba37989..3c027a9 100644 --- a/themes/default/layouts/_default/_markup/render-image.html +++ b/themes/default/layouts/_default/_markup/render-image.html @@ -5,7 +5,7 @@ {{- $width := "" -}} {{- $height := "" -}} {{- $cache := "" -}} -{{- $dimensions := "x360" -}} +{{- $dimensions := "600x360" -}} {{- with $remote -}} {{- with .Err -}} @@ -33,16 +33,16 @@ <a href="{{ $source }}"> <picture> {{- with $local }} - <source srcset="{{- ($local.Resize (print $dimensions " webp")).RelPermalink -}}" type="image/webp" /> - {{- $local = $local.Resize $dimensions }} + <source srcset="{{- ($local.Fit (print $dimensions " webp")).RelPermalink -}}" type="image/webp" /> + {{- $local = $local.Fit $dimensions }} {{- $width = $local.Width -}} {{- $height = $local.Height -}} {{- end }} {{- with $cache }} {{- $cache = .Content | resources.FromString (print "/data/static/images/" (. | urlize)) }} - <source srcset="{{- ($cache.Resize (print $dimensions " webp")).RelPermalink -}}" type="image/webp" /> + <source srcset="{{- ($cache.Fit (print $dimensions " webp")).RelPermalink -}}" type="image/webp" /> {{- $cache = .Content | resources.FromString (. | urlize) -}} - {{- $cache = $cache.Resize $dimensions }} + {{- $cache = $cache.Fit $dimensions }} {{- $width = $cache.Width -}} {{- $height = $cache.Height -}} {{- $cache = $cache.RelPermalink }} diff --git a/themes/default/layouts/partials/author-card.html b/themes/default/layouts/partials/author-card.html index b05daa5..efdf256 100644 --- a/themes/default/layouts/partials/author-card.html +++ b/themes/default/layouts/partials/author-card.html @@ -1,5 +1,6 @@ -{{- $path := print "public/" .Data.user "/media/profile/picture.png" -}} -{{- $image := resources.Get $path -}} +{{- $path := print "public/" .Data.user "/media/profile/picture.png" -}} +{{- $image := resources.Get $path -}} +{{- $dimensions := "96x96" -}} <micro-author> <micro-card> @@ -10,15 +11,13 @@ <picture> {{- with $image }} {{- $image = .Content | resources.FromString (print "/data/static/images/" ($image | urlize)) }} - <source srcset="{{- ($image.Resize "x64 png").RelPermalink -}}" type="image/png" /> - <source srcset="{{- ($image.Resize "x64 jpg").RelPermalink -}}" type="image/jpeg" /> - <source srcset="{{- ($image.Resize "x64 webp").RelPermalink -}}" type="image/webp" /> + <source srcset="{{- ($image.Fit (print $dimensions " webp")).RelPermalink -}}" type="image/webp" /> {{- end }} <img alt="{{ .Data.name }}" {{- if fileExists $path }} {{ with $image }} - {{- $image = (.Content | resources.FromString (print "/data/static/images/" ($image | urlize))).Resize "x64" -}} + {{- $image = (.Content | resources.FromString (print "/data/static/images/" ($image | urlize))).Fit $dimensions -}} width="{{ $image.Width }}" height="{{ $image.Height }}" src="{{ $image.RelPermalink }}" diff --git a/themes/default/layouts/partials/author-header.html b/themes/default/layouts/partials/author-header.html index 0261915..18738c4 100644 --- a/themes/default/layouts/partials/author-header.html +++ b/themes/default/layouts/partials/author-header.html @@ -3,18 +3,18 @@ {{- $image := resources.Get $path -}} {{- $404origin := print "/images/404.png" -}} {{- $404image := imageConfig (print "static/" $404origin) -}} -{{- $dimensions := "x360" -}} +{{- $dimensions := "600x360" -}} {{- with $image -}} {{- $image = .Content | resources.FromString (print "/data/static/images/" (. | urlize)) -}} - <source srcset="{{- ($image.Resize (print $dimensions " webp")).RelPermalink -}}" type="image/webp" /> + <source srcset="{{- ($image.Fit (print $dimensions " webp")).RelPermalink -}}" type="image/webp" /> {{- end -}} <img loading="lazy" {{ if fileExists $path }} {{- with $image -}} - {{- $image = (.Content | resources.FromString (print "/data/static/images/" ($image | urlize))).Resize $dimensions -}} + {{- $image = (.Content | resources.FromString (print "/data/static/images/" ($image | urlize))).Fit $dimensions -}} width="{{ $image.Width }}" height="{{ $image.Height }}" src="{{ $image.RelPermalink }}" diff --git a/themes/default/layouts/partials/author-picture.html b/themes/default/layouts/partials/author-picture.html index f0a0849..e583233 100644 --- a/themes/default/layouts/partials/author-picture.html +++ b/themes/default/layouts/partials/author-picture.html @@ -1,16 +1,15 @@ -{{- $file := "/profile/picture.png" -}} -{{- $path := print "public/" (partial "author-media-path.html" .) $file -}} -{{- $image := resources.Get $path -}} -{{- $404origin := print "/images/404.png" -}} -{{- $404image := imageConfig (print "static/" $404origin) -}} +{{- $file := "/profile/picture.png" -}} +{{- $path := print "public/" (partial "author-media-path.html" .) $file -}} +{{- $image := resources.Get $path -}} +{{- $404origin := print "/images/404.png" -}} +{{- $404image := imageConfig (print "static/" $404origin) -}} +{{- $dimensions := "96x96" -}} {{- with .Params.feed -}} {{- else -}} {{- with $image -}} {{- $image = .Content | resources.FromString (print "/data/static/images/" ($image | urlize)) -}} - <source srcset="{{- ($image.Resize "x120 png").RelPermalink -}}" type="image/png" /> - <source srcset="{{- ($image.Resize "x120 jpg").RelPermalink -}}" type="image/jpeg" /> - <source srcset="{{- ($image.Resize "x120 webp").RelPermalink -}}" type="image/webp" /> + <source srcset="{{- ($image.Fit (print $dimensions " webp")).RelPermalink -}}" type="image/webp" /> {{- end -}} {{ end }} @@ -24,7 +23,7 @@ {{ else }} {{ if fileExists $path }} {{- with $image -}} - {{- $image = (.Content | resources.FromString (print "/data/static/images/" ($image | urlize))).Resize "x120" -}} + {{- $image = (.Content | resources.FromString (print "/data/static/images/" ($image | urlize))).Fit $dimensions -}} width="{{ $image.Width }}" height="{{ $image.Height }}" src="{{ $image.RelPermalink }}" diff --git a/themes/default/layouts/partials/gallery-walk.html b/themes/default/layouts/partials/gallery-walk.html index 0607fb5..efccb4a 100644 --- a/themes/default/layouts/partials/gallery-walk.html +++ b/themes/default/layouts/partials/gallery-walk.html @@ -1,4 +1,5 @@ -{{- $folder := . }} +{{- $folder := . -}} +{{- $dimensions := "320x320" -}} {{- if fileExists $folder }} {{- $files := readDir $folder }} @@ -25,7 +26,7 @@ }} {{- with $image := resources.Get $path -}} - {{- $imageContent := (.Content | resources.FromString (print "/data/static/images/" ($image | urlize))).Resize "x100" }} + {{- $imageContent := (.Content | resources.FromString (print "/data/static/images/" ($image | urlize))).Fit $dimensions }} <img alt="{{- .Name }}" title="{{- .Name }}" |
