1
0
mirror of https://github.com/danbee/danbarber.me.hugo.git synced 2025-03-04 08:59:18 +00:00

Improve image resizing quality

This commit is contained in:
Daniel Barber 2019-10-11 22:51:50 -04:00
parent acfb4eb268
commit eadc747387
2 changed files with 10 additions and 10 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 KiB

After

Width:  |  Height:  |  Size: 3.2 MiB

View File

@ -3,10 +3,10 @@
{{/* set image sizes, these are hardcoded for now, x dictates that images are resized to this width */}} {{/* set image sizes, these are hardcoded for now, x dictates that images are resized to this width */}}
{{ $tinyw := default "408x" }} {{ $tinyw := default "408x Lanczos" }}
{{ $smallw := default "816x" }} {{ $smallw := default "816x Lanczos" }}
{{ $mediumw := default "1224x" }} {{ $mediumw := default "1224x Lanczos" }}
{{ $largew := default "1632x" }} {{ $largew := default "1632x Lanczos" }}
{{/* resize the src image to the given sizes */}} {{/* resize the src image to the given sizes */}}
@ -28,16 +28,16 @@
<img <img
{{ with .Get "sizes" }}sizes='{{.}}'{{ else }}sizes="(min-width: 35em) 1200px, 100vw"{{ end }} {{ with .Get "sizes" }}sizes='{{.}}'{{ else }}sizes="(min-width: 35em) 1200px, 100vw"{{ end }}
srcset=' srcset='
{{ if ge $src.Width "408" }} {{ if ge $src.Width "400" }}
{{ with $tiny.RelPermalink }}{{.}} 408w{{ end }} {{ with $tiny.RelPermalink }}{{.}} 408w{{ end }}
{{ end }} {{ end }}
{{ if ge $src.Width "816" }} {{ if ge $src.Width "800" }}
{{ with $small.RelPermalink }}, {{.}} 816w{{ end }} {{ with $small.RelPermalink }}, {{.}} 816w{{ end }}
{{ end }} {{ end }}
{{ if ge $src.Width "1224" }} {{ if ge $src.Width "1200" }}
{{ with $medium.RelPermalink }}, {{.}} 1224w{{ end }} {{ with $medium.RelPermalink }}, {{.}} 1224w{{ end }}
{{ end }} {{ end }}
{{ if ge $src.Width "1632" }} {{ if ge $src.Width "1600" }}
{{ with $large.RelPermalink }}, {{.}} 1632w {{ end }} {{ with $large.RelPermalink }}, {{.}} 1632w {{ end }}
{{ end }}' {{ end }}'
{{ if .Get $medium }} {{ if .Get $medium }}