force jpeg format for avatar download in NSE
CDN may serve WebP by default which INImage doesn't reliably handle. Append @jpeg to the URL to request JPEG format instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -118,11 +118,19 @@ class NotificationService: UNNotificationServiceExtension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func downloadAvatarImage(from urlString: String) -> INImage? {
|
func downloadAvatarImage(from urlString: String) -> INImage? {
|
||||||
let thumbnailUrlString = urlString.replacingOccurrences(
|
var thumbnailUrlString = urlString.replacingOccurrences(
|
||||||
of: "/img/avatar/",
|
of: "/img/avatar/",
|
||||||
with: "/img/avatar_thumbnail/"
|
with: "/img/avatar_thumbnail/"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// CDN URLs may end with @webp or no extension (which defaults to webp).
|
||||||
|
// INImage doesn't reliably handle WebP, so force JPEG.
|
||||||
|
if let atRange = thumbnailUrlString.range(of: "@", options: .backwards) {
|
||||||
|
thumbnailUrlString = String(thumbnailUrlString[..<atRange.lowerBound]) + "@jpeg"
|
||||||
|
} else {
|
||||||
|
thumbnailUrlString += "@jpeg"
|
||||||
|
}
|
||||||
|
|
||||||
guard let url = URL(string: thumbnailUrlString) else { return nil }
|
guard let url = URL(string: thumbnailUrlString) else { return nil }
|
||||||
|
|
||||||
var request = URLRequest(url: url)
|
var request = URLRequest(url: url)
|
||||||
|
|||||||
Reference in New Issue
Block a user