Skip to content

Commit

Permalink
[iOS] Using image cache when calling query cache after preload images
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongwuzw committed Dec 17, 2024
1 parent 5c789c3 commit 0e60ad9
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/react-native/Libraries/Image/RCTImageLoader.mm
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,14 @@ - (RCTImageURLLoaderRequest *)_loadImageOrDataWithURLRequest:(NSURLRequest *)req
size:size
scale:scale
resizeMode:resizeMode];
// Retrieve original image and resize it
if (!image && !(CGSizeEqualToSize(size, CGSizeZero) && scale == 1 && resizeMode == RCTResizeModeStretch)) {
image = [[strongSelf imageCache] imageForUrl:request.URL.absoluteString
size:CGSizeZero
scale:1
resizeMode:RCTResizeModeStretch];
image = RCTResizeImageIfNeeded(image, size, scale, resizeMode);
}
}

if (image) {
Expand Down Expand Up @@ -1085,6 +1093,14 @@ - (NSDictionary *)getImageCacheStatus:(NSArray *)requests
} else {
results[urlRequest.URL.absoluteString] = @"disk/memory";
}
} else {
UIImage *image = [_imageCache imageForUrl:urlRequest.URL.absoluteString
size:CGSizeZero
scale:1
resizeMode:RCTResizeModeStretch];
if (image) {
results[urlRequest.URL.absoluteString] = @"memory";
}
}
}
}
Expand Down

0 comments on commit 0e60ad9

Please sign in to comment.