* fix: add SVG check in helper/image before accessing .Width and .Height * refactor: drop image resizing logic in render-image, and use helper/image to process image * fix: render-image $permalink not correct
19 lines
703 B
HTML
19 lines
703 B
HTML
{{- $image := partial "helper/image" (dict "Resources" .Page.Resources "Image" .Destination) -}}
|
|
{{- $alt := .PlainText | safeHTML -}}
|
|
|
|
{{/* SVG and external images won't work with gallery layout, because their width and height attributes are unknown */}}
|
|
{{- $galleryImage := and $image.Height $image.Width -}}
|
|
|
|
<img src="{{ $image.Permalink }}"
|
|
{{ with $image.Width }}width="{{ . }}"{{ end }}
|
|
{{ with $image.Height }}height="{{ . }}"{{ end }}
|
|
loading="lazy"
|
|
{{ with $alt }}
|
|
alt="{{ . }}"
|
|
{{ end }}
|
|
{{ if $galleryImage }}
|
|
class="gallery-image"
|
|
data-flex-grow="{{ div (mul $image.Width 100) $image.Height }}"
|
|
data-flex-basis="{{ div (mul $image.Width 240) $image.Height }}px"
|
|
{{ end }}
|
|
> |