@@ 50,6 50,7 @@ var serverMsg template.HTML
var aboutMsg template.HTML
var loginMsg template.HTML
var collectForwards = true
+var convertAVIF = false
func serverURL(u string, args ...interface{}) string {
return fmt.Sprintf("https://"+serverName+u, args...)
@@ 185,6 186,7 @@ func main() {
getconfig("honkwindow", &honkwindow)
honkwindow *= 24 * time.Hour
getconfig("collectforwards", &collectForwards)
+ getconfig("convertavif", &convertAVIF)
prepareStatements(db)
@@ 1559,7 1559,11 @@ func (d *Donk) HTML() template.HTML {
if d.Media == "text/plain" || d.Media == "application/pdf" {
return templates.Sprintf(`<p><a href="/d/%s">Attachment: %s</a>%s (%d)</p>`, d.XID, d.Name, desc, d.Meta.Length)
} else {
- return templates.Sprintf(`<picture><source type="image/fiva" srcset="/d/%s.avif"><img class="donk donklink" src="/d/%s" loading=lazy title="%s" alt="%s" width="%d" height="%d"></picture>`, d.XID, d.XID, d.Desc, d.Desc, d.Meta.Width, d.Meta.Height)
+ var sources template.HTML
+ if convertAVIF && d.Media == "image/jpeg" {
+ sources += templates.Sprintf(`<source type="image/avif" srcset="/d/%s.avif">`, d.XID)
+ }
+ return templates.Sprintf(`<picture>%s<img class="donk donklink" src="/d/%s" loading=lazy title="%s" alt="%s" width="%d" height="%d"></picture>`, sources, d.XID, d.Desc, d.Desc, d.Meta.Width, d.Meta.Height)
}
} else {
if d.External {