Skip to content

Commit 456a984

Browse files
zhongwuzwgrabbou
authored andcommitted
Fix image wrong scale factor when load image from file system (facebook#23446)
Summary: Regression, fix image load from `~/Library` not respect scale factor. Fixes facebook#22383 , the bug comes from [Clean up some URL path handling](facebook@998197f). [iOS] [Fixed] - Fix image wrong scale factor when load image from file system Pull Request resolved: facebook#23446 Differential Revision: D14099614 Pulled By: cpojer fbshipit-source-id: eb2267b195a05eb70cdc4671536a4c1d47fb03e2
1 parent 8d95e73 commit 456a984

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

React/Base/RCTUtils.m

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -708,13 +708,11 @@ BOOL RCTIsLocalAssetURL(NSURL *__nullable imageURL)
708708

709709
if (!image) {
710710
// Attempt to load from the file system
711-
NSData *fileData;
712-
if (imageURL.pathExtension.length == 0) {
713-
fileData = [NSData dataWithContentsOfURL:[imageURL URLByAppendingPathExtension:@"png"]];
714-
} else {
715-
fileData = [NSData dataWithContentsOfURL:imageURL];
711+
NSString *filePath = [NSString stringWithUTF8String:[imageURL fileSystemRepresentation]];
712+
if (filePath.pathExtension.length == 0) {
713+
filePath = [filePath stringByAppendingPathExtension:@"png"];
716714
}
717-
image = [UIImage imageWithData:fileData];
715+
image = [UIImage imageWithContentsOfFile:filePath];
718716
}
719717

720718
if (!image && !bundle) {

0 commit comments

Comments
 (0)