Fix image wrong scale factor when load image from file system (#23446)

Summary:
Regression, fix image load from `~/Library` not respect scale factor.
Fixes #22383 , the bug comes from [Clean up some URL path handling](https://github.com/facebook/react-native/commit/998197f444aca06cde0d5258469b3d314f8ea8b9).

[iOS] [Fixed] - Fix image wrong scale factor when load image from file system
Pull Request resolved: https://github.com/facebook/react-native/pull/23446

Differential Revision: D14099614

Pulled By: cpojer

fbshipit-source-id: eb2267b195a05eb70cdc4671536a4c1d47fb03e2
This commit is contained in:
zhongwuzw
2019-03-11 21:20:02 +01:00
committed by Mike Grabowski
parent 8d95e734bb
commit 456a984722
+4 -6
View File
@@ -708,13 +708,11 @@ UIImage *__nullable RCTImageFromLocalAssetURL(NSURL *imageURL)
if (!image) {
// Attempt to load from the file system
NSData *fileData;
if (imageURL.pathExtension.length == 0) {
fileData = [NSData dataWithContentsOfURL:[imageURL URLByAppendingPathExtension:@"png"]];
} else {
fileData = [NSData dataWithContentsOfURL:imageURL];
NSString *filePath = [NSString stringWithUTF8String:[imageURL fileSystemRepresentation]];
if (filePath.pathExtension.length == 0) {
filePath = [filePath stringByAppendingPathExtension:@"png"];
}
image = [UIImage imageWithData:fileData];
image = [UIImage imageWithContentsOfFile:filePath];
}
if (!image && !bundle) {