Skip to content

Commit e3f2c02

Browse files
authored
Merge pull request #2 from SDWebImage/bugfix_first_frame_only_memory
Fix the case when `SDWebImageFirstFrameOnly` hit memory cache, the animated image still been provided
2 parents f4dd0c5 + e8a0188 commit e3f2c02

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Example/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PODS:
22
- Expecta (1.0.6)
3-
- SDWebImage/Core (5.0.0)
3+
- SDWebImage/Core (5.0.2)
44
- SDWebImageYYPlugin (0.2.0):
55
- SDWebImage/Core (~> 5.0)
66
- SDWebImageYYPlugin/YYCache (= 0.2.0)
@@ -34,7 +34,7 @@ EXTERNAL SOURCES:
3434

3535
SPEC CHECKSUMS:
3636
Expecta: 3b6bd90a64b9a1dcb0b70aa0e10a7f8f631667d5
37-
SDWebImage: 5de80a0302de9e377e62f47d2fa1304efff0e55f
37+
SDWebImage: 6764b5fa0f73c203728052955dbefa2bf1f33282
3838
SDWebImageYYPlugin: 3398b1f1016cd30d8fdb857226c254a0da8b1a11
3939
YYCache: 8105b6638f5e849296c71f331ff83891a4942952
4040
YYImage: 1e1b62a9997399593e4b9c4ecfbbabbf1d3f3b54

SDWebImageYYPlugin/Classes/YYCache/YYCacheBridge/YYCache+SDAdditions.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ @implementation YYCache (SDAdditions)
4545

4646
// First check the in-memory cache...
4747
UIImage *image = [self.memoryCache objectForKey:key];
48+
49+
if ((options & SDImageCacheDecodeFirstFrameOnly) && image.sd_isAnimated) {
50+
#if SD_MAC
51+
image = [[NSImage alloc] initWithCGImage:image.CGImage scale:image.scale orientation:kCGImagePropertyOrientationUp];
52+
#else
53+
image = [[UIImage alloc] initWithCGImage:image.CGImage scale:image.scale orientation:image.imageOrientation];
54+
#endif
55+
}
56+
4857
BOOL shouldQueryMemoryOnly = (image && !(options & SDImageCacheQueryMemoryData));
4958
if (shouldQueryMemoryOnly) {
5059
if (doneBlock) {

0 commit comments

Comments
 (0)