mirror of
https://github.com/tulir/mautrix-whatsapp
synced 2024-12-13 09:03:10 +01:00
Add hack for working around image rendering in broken clients
Closes #589
This commit is contained in:
parent
edc682c657
commit
08fe836b8a
1 changed files with 11 additions and 0 deletions
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))
|
||||
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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue