1
Fork 0
theorangeone.net-legacy/layouts/shortcodes/resource.html

31 lines
821 B
HTML

{{ $original := .Page.Resources.GetMatch (.Get "src") }}
{{ $options := default "1000x" (.Get "options") }}
{{ .Scratch.Set "image" $original }}
{{ $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 }}
{{ define "img" }}
{{ $image := .Scratch.Get "image" }}
<img src='{{ $image.RelPermalink }}' class='{{ .Get "class" }}' alt="{{ .Inner | plainify }}" />
{{ end }}
{{ if .Inner }}
<figure>
{{ template "img" . }}
<figcaption>
<small>{{ .Inner }}</small>
</figcaption>
</figure>
{{ else }}
{{ template "img" . }}
{{ end }}