Skip to content

Commit

Permalink
Fix image wrong scale factor when load image from file system (#23446)
Browse files Browse the repository at this point in the history
Summary:
Regression, fix image load from `~/Library` not respect scale factor.
Fixes #22383 , the bug comes from [Clean up some URL path handling](998197f).

[iOS] [Fixed] - Fix image wrong scale factor when load image from file system
Pull Request resolved: #23446

Differential Revision: D14099614

Pulled By: cpojer

fbshipit-source-id: eb2267b195a05eb70cdc4671536a4c1d47fb03e2
  • Loading branch information
zhongwuzw authored and grabbou committed Mar 11, 2019
1 parent 8d95e73 commit 456a984
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions React/Base/RCTUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -708,13 +708,11 @@ BOOL RCTIsLocalAssetURL(NSURL *__nullable 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) {
Expand Down

0 comments on commit 456a984

Please sign in to comment.