Resize images in header and shortcode
This commit is contained in:
parent
7c66db75df
commit
b03b06331e
2 changed files with 10 additions and 11 deletions
|
@ -2,7 +2,7 @@
|
||||||
{{ .Scratch.Set "image" .Params.image }}
|
{{ .Scratch.Set "image" .Params.image }}
|
||||||
{{ if hasPrefix .Params.image "resource:" }}
|
{{ if hasPrefix .Params.image "resource:" }}
|
||||||
{{ $resource := .Resources.GetMatch (replace .Params.image "resource:" "") }}
|
{{ $resource := .Resources.GetMatch (replace .Params.image "resource:" "") }}
|
||||||
{{ .Scratch.Set "image" $resource.RelPermalink }}
|
{{ .Scratch.Set "image" ($resource.Resize "1000x").RelPermalink }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<div class="mb-3 image header-image" data-image='{{ .Scratch.Get "image" }}'></div>
|
<div class="mb-3 image header-image" data-image='{{ .Scratch.Get "image" }}'></div>
|
||||||
{{ end }}{{ end }}
|
{{ end }}{{ end }}
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
{{ $original := .Page.Resources.GetMatch (.Get "src") }}
|
{{ $original := .Page.Resources.GetMatch (.Get "src") }}
|
||||||
{{ $options := .Get "options" }}
|
{{ $options := default "1000x" (.Get "options") }}
|
||||||
|
|
||||||
{{ .Scratch.Set "image" $original }}
|
{{ .Scratch.Set "image" $original }}
|
||||||
|
|
||||||
{{ if $options }}
|
{{ $command := (default "Resize" (.Get "command")) }}
|
||||||
{{ $command := (default "Resize" (.Get "command")) }}
|
|
||||||
{{ if eq $command "Fit"}}
|
{{ if eq $command "Fit"}}
|
||||||
{{ .Scratch.Set "image" ($original.Fit $options) }}
|
{{ .Scratch.Set "image" ($original.Fit $options) }}
|
||||||
{{ else if eq $command "Resize"}}
|
{{ else if eq $command "Resize"}}
|
||||||
{{ .Scratch.Set "image" ($original.Resize $options) }}
|
{{ .Scratch.Set "image" ($original.Resize $options) }}
|
||||||
{{ else if eq $command "Fill"}}
|
{{ else if eq $command "Fill"}}
|
||||||
{{ .Scratch.Set "image" ($original.Fill $options) }}
|
{{ .Scratch.Set "image" ($original.Fill $options) }}
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ $image := .Scratch.Get "image" }}
|
{{ $image := .Scratch.Get "image" }}
|
||||||
|
|
Loading…
Reference in a new issue