sitoctt/layouts/partials/ImgButton.html

27 lines
793 B
HTML
Raw Normal View History

{{- $size := (or .size "88x31") -}}
{{- $sizes := (split $size "x") -}}
{{- $alt := (or (and .alt (printf "[%s]" .alt)) "") -}}
{{- $src := (or
.src
(printf `%s/Media/Buttons/%s/%s`
(partial "assetsRoot.html")
$size
.srcRelative)) -}}
{{- $style := (or .style "") -}}
{{- if (and (not $style) (not (eq (index (last 1 (split $src ".")) 0) "svg"))) -}}
{{- $style = "image-rendering: pixelated;" -}}
{{- end -}}
{{/* TODO: maybe set rendering via a class instead of inline CSS? */}}
{{- $img := (printf `<img src="%s" style="%s" alt="%s" title="%s" width="%spx" height="%spx" />`
$src $style
$alt $alt
(index $sizes 0) (index $sizes 1)
) | safeHTML -}}
2024-08-29 00:35:27 +02:00
{{ if .href }}
{{ partial "anchor.html" (dict
"Inner" $img
"Params" .) }}
2024-08-29 00:35:27 +02:00
{{ else }}
{{ $img }}
2024-08-29 00:35:27 +02:00
{{ end }}