diff --git a/config/_default/params.toml b/config/_default/params.toml index 2d0d06c..0774ebd 100644 --- a/config/_default/params.toml +++ b/config/_default/params.toml @@ -48,6 +48,7 @@ bgColor = "#fff" landscapePhotoWidths = [900, 800, 700, 600, 500] portraitPhotoWidths = [800, 700, 600, 500] lqipWidth = "20x" +smallLimit = "300" # Footer footer = "Powered by Netlify, Hugo, and Doks" diff --git a/layouts/_default/_markup/render-image.html b/layouts/_default/_markup/render-image.html new file mode 100644 index 0000000..18e7a3c --- /dev/null +++ b/layouts/_default/_markup/render-image.html @@ -0,0 +1,27 @@ +{{ $image := .Page.Resources.GetMatch .Destination -}} +{{ $lqip := $image.Resize site.Params.lqipWidth -}} + +{{ $imgSrc := "" -}} +{{ $imgSrcSet := slice -}} + +{{ $widths := site.Params.landscapePhotoWidths -}} +{{ if gt $image.Height $image.Width -}} + {{ $widths = site.Params.portraitPhotoWidths -}} +{{ end -}} + +{{ range $widths -}} + {{ $srcUrl := (printf "%dx" . | $image.Resize).Permalink -}} + {{ if eq $imgSrc "" -}}{{ $imgSrc = $srcUrl -}}{{ end -}} + {{ $imgSrcSet = $imgSrcSet | append (printf "%s %dw" $srcUrl .) -}} +{{ end -}} +{{ $imgSrcSet = (delimit $imgSrcSet ",") -}} + +{{ if gt $image.Width site.Params.smallLimit -}} +
+ {{ $.Text }} + + {{ with $.Title }}
{{ . | safeHTML }}
{{ end -}} +
+{{ else -}} + {{ $.Text }} +{{ end -}}