aboutsummaryrefslogtreecommitdiff
path: root/echo/tplfuncs/picture_tag.go
blob: ddec4aafb88f31935a8d5bf3da2720ca621ec75d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package tplfuncs

import (
	"fmt"
	"html/template"
)

// RenderPictureTag renders a picture tag with a webp and jpeg source
// and alt text.
func RenderPictureTag(img, alt string) template.HTML {
	return template.HTML(fmt.Sprintf(`<picture>
	<source srcset="%s.webp" type="image/webp" />
	<source srcset="%s.jpg" type="image/jpeg" />
	<img src="%s.jpg" alt="%s" loading="lazy" />
</picture>`, img, img, img, alt))
}