Skip to content

Commit

Permalink
Merge pull request #1935 from onevcat/fix/reload-animated-options
Browse files Browse the repository at this point in the history
Choose to recreate animated image
  • Loading branch information
onevcat authored Apr 22, 2022
2 parents bef0d09 + c5236b6 commit 61f9dba
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Sources/General/KingfisherManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -521,10 +521,18 @@ public class KingfisherManager {
result.match(
onSuccess: { cacheResult in
let value: Result<RetrieveImageResult, KingfisherError>
if let image = cacheResult.image {
if var image = cacheResult.image {
if image.kf.imageFrameCount != nil && image.kf.imageFrameCount != 1, let data = image.kf.animatedImageData {
// Always recreate animated image representation since it is possible to be loaded in different options.
// https://github.com/onevcat/Kingfisher/issues/1923
image = KingfisherWrapper.animatedImage(data: data, options: options.imageCreatingOptions) ?? .init()
}
if let modifier = options.imageModifier {
image = modifier.modify(image)
}
value = result.map {
RetrieveImageResult(
image: options.imageModifier?.modify(image) ?? image,
image: image,
cacheType: $0.cacheType,
source: source,
originalSource: context.originalSource
Expand Down

0 comments on commit 61f9dba

Please sign in to comment.