erynwells.me/layouts/shortcodes/img.html
Eryn Wells 383234e983 Address all warnings during the Hugo build
- Add descriptions for pages that have too much content
- Add an image orientation override param so that I can specify orientation when it's missing from EXIF
- Move the author.name and author.email configurations to params; delete author.yaml
2023-12-18 11:22:14 -08:00

21 lines
651 B
HTML

{{ $img := dict }}
{{ with .Get "name" }}
{{ $img = $.Page.Resources.GetMatch . }}
{{ else }}
{{ errorf "No name given to img shortcode" }}
{{ end }}
{{/* Space separated list of classes to apply to the <img> tag */}}
{{ $classes := .Get "class" }}
{{ $altText := .Get "alt" | default $img.Params.alt }}
{{ if not $altText }}
{{ warnf "Image doesn't have alt text: %s" $img.RelPermalink }}
{{ end }}
{{ $resizedImg := $img.Fit "1280x1280" }}
<img src="{{ $resizedImg.RelPermalink }}"
width="{{ $resizedImg.Width }}"
height="{{ $resizedImg.Height }}"
alt="{{ $altText }}"
{{ with $classes }}class="{{ . }}"{{ end }}>