From b03b06331eb0141de3868615fc097ff2a1836db1 Mon Sep 17 00:00:00 2001 From: Jake Date: Sun, 4 Mar 2018 10:39:41 +0000 Subject: [PATCH] Resize images in header and shortcode --- layouts/partials/content.html | 2 +- layouts/shortcodes/resource.html | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/layouts/partials/content.html b/layouts/partials/content.html index 6d932d1..313108a 100644 --- a/layouts/partials/content.html +++ b/layouts/partials/content.html @@ -2,7 +2,7 @@ {{ .Scratch.Set "image" .Params.image }} {{ if hasPrefix .Params.image "resource:" }} {{ $resource := .Resources.GetMatch (replace .Params.image "resource:" "") }} - {{ .Scratch.Set "image" $resource.RelPermalink }} + {{ .Scratch.Set "image" ($resource.Resize "1000x").RelPermalink }} {{ end }}
{{ end }}{{ end }} diff --git a/layouts/shortcodes/resource.html b/layouts/shortcodes/resource.html index 419eca6..1829952 100644 --- a/layouts/shortcodes/resource.html +++ b/layouts/shortcodes/resource.html @@ -1,17 +1,16 @@ {{ $original := .Page.Resources.GetMatch (.Get "src") }} -{{ $options := .Get "options" }} +{{ $options := default "1000x" (.Get "options") }} {{ .Scratch.Set "image" $original }} -{{ if $options }} - {{ $command := (default "Resize" (.Get "command")) }} - {{ if eq $command "Fit"}} - {{ .Scratch.Set "image" ($original.Fit $options) }} - {{ else if eq $command "Resize"}} - {{ .Scratch.Set "image" ($original.Resize $options) }} - {{ else if eq $command "Fill"}} - {{ .Scratch.Set "image" ($original.Fill $options) }} - {{ end }} +{{ $command := (default "Resize" (.Get "command")) }} + +{{ if eq $command "Fit"}} + {{ .Scratch.Set "image" ($original.Fit $options) }} +{{ else if eq $command "Resize"}} + {{ .Scratch.Set "image" ($original.Resize $options) }} +{{ else if eq $command "Fill"}} + {{ .Scratch.Set "image" ($original.Fill $options) }} {{ end }} {{ $image := .Scratch.Get "image" }}