12345678910111213141516171819202122232425262728293031323334353637 |
- <picture{{ with .wrapperClass }} class="{{ . }}"{{ end }}>
- {{- range .sources }}
- <source srcset="{{ .srcset }}" type="{{ .type }}" />
- {{- end }}
- {{- $attrs := slice
- (printf `class="%s"` .className)
- (printf `src="%s"` .src)
- (printf `alt="%s"` .alt)
- }}
- {{- with .caption }}
- {{- $attrs = $attrs | append (printf `title="%s"` .) }}
- {{- end }}
- {{- if .lazyLoading }}
- {{- $attrs = $attrs | append `loading="lazy"` }}
- {{- end }}
- {{- with .naturalHeight }}
- {{- $attrs = $attrs | append (printf `height="%s"` (string .)) }}
- {{- end }}
- {{- with .naturalWidth }}
- {{- $attrs = $attrs | append (printf `width="%s"` (string .)) }}
- {{- end }}
- {{- with .style }}
- {{- $attrs = $attrs | append (printf `style="%s"` (delimit . `; `)) }}
- {{- end }}
- {{- if .original }}
- {{- with .originalSrc }}
- {{- $attrs = $attrs | append (printf `data-src="%s"` .) }}
- {{- end }}
- {{- with .originalWidth }}
- {{- $attrs = $attrs | append (printf `data-width="%s"` (string .)) }}
- {{- end }}
- {{- with .originalHeight }}
- {{- $attrs = $attrs | append (printf `data-height="%s"` (string .)) }}
- {{- end }}
- {{- end }}
- <img {{ delimit $attrs " " | safeHTMLAttr }} />
- </picture>
|