mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-05-22 05:43:49 +02:00
Add hack for working around image rendering in broken clients
Closes #589
This commit is contained in:
parent
edc682c657
commit
08fe836b8a
11
portal.go
11
portal.go
|
@ -2972,6 +2972,17 @@ func (portal *Portal) uploadMedia(intent *appservice.IntentAPI, data []byte, con
|
||||||
cfg, _, _ := image.DecodeConfig(bytes.NewReader(data))
|
cfg, _, _ := image.DecodeConfig(bytes.NewReader(data))
|
||||||
content.Info.Width, content.Info.Height = cfg.Width, cfg.Height
|
content.Info.Width, content.Info.Height = cfg.Width, cfg.Height
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is a hack for bad clients like Element iOS that require a thumbnail (https://github.com/vector-im/element-ios/issues/4004)
|
||||||
|
if strings.HasPrefix(content.Info.MimeType, "image/") && content.Info.ThumbnailInfo == nil {
|
||||||
|
infoCopy := *content.Info
|
||||||
|
content.Info.ThumbnailInfo = &infoCopy
|
||||||
|
if content.File != nil {
|
||||||
|
content.Info.ThumbnailFile = file
|
||||||
|
} else {
|
||||||
|
content.Info.ThumbnailURL = content.URL
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue