Skip to content

Commit

Permalink
MBL-1421: Use webp-compatible processor and cache serializer
Browse files Browse the repository at this point in the history
This fixes an issue where animated webp images were not being displayed - only their first frame.
The webp code will fall back to Kingfisher defaults for non-webp images.
  • Loading branch information
amy-at-kickstarter committed May 23, 2024
1 parent 33ad3dd commit 403a353
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions Kickstarter-iOS/Library/UIImageView+URL.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import AlamofireImage
import Kingfisher
import KingfisherWebP
import ReactiveExtensions
import ReactiveSwift
import UIKit
Expand Down Expand Up @@ -36,11 +37,20 @@ extension UIImageView {

public static func ksr_cacheImageWith(
_ url: URL,
serializer _: CacheSerializer = DefaultCacheSerializer(),
completionHandler: @escaping (UIImage?) -> Void
) {
/* WebPProcessor and WebPSerializer fall back to
DefaultImageProcessor and DefaultCacheSerializer, respectively,
for non-webp images */

let options: KingfisherOptionsInfo = [
.processor(WebPProcessor.default),
.cacheSerializer(WebPSerializer.default)
]

let prefetcher = ImagePrefetcher(
resources: [url]
resources: [url],
options: options
) { cachedImages, failedImages, downloadedImages in
var crossPlatformImage: UIImage?

Expand All @@ -52,7 +62,8 @@ extension UIImageView {
}

ImageCache.default.retrieveImage(
forKey: image.cacheKey
forKey: image.cacheKey,
options: options
) { result in

switch result {
Expand Down

0 comments on commit 403a353

Please sign in to comment.