Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 23909cd

Browse files
committed
[Image] Support loading images from application home directory.
Summary: Image source uri's prefixed with ~ are expanded into a full path to the app directory. For example: `~/Documents/foo.png` is expanded into `Users/arbesfeld/Library/Developer/CoreSimulator/Devices/977988DF-A8BC-4CE5-A27A-75807A6DF085/data/Containers/Data/Application/CBEFC261-5900-4EF9-8646-603BC57B094A/Documents/foo.png`. This lets us store and use images from the application home directory with the `Image` component: ``` <Image source={{uri: '~/Documents/foo.png', width: 300, height: 300}} /> ``` Resolves facebook#1178 Closes facebook#1740 Github Author: Matthew Arbesfeld <[email protected]>
1 parent e1f53c0 commit 23909cd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

React/Base/RCTConvert.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -671,8 +671,8 @@ + (UIImage *)UIImage:(id)json
671671
NSURL *url = [NSURL URLWithString:path];
672672
NSData *imageData = [NSData dataWithContentsOfURL:url];
673673
image = [UIImage imageWithData:imageData];
674-
} else if ([path isAbsolutePath]) {
675-
image = [UIImage imageWithContentsOfFile:path];
674+
} else if ([path isAbsolutePath] || [path hasPrefix:@"~"]) {
675+
image = [UIImage imageWithContentsOfFile:path.stringByExpandingTildeInPath];
676676
} else {
677677
image = [UIImage imageNamed:path];
678678
if (!image) {

0 commit comments

Comments
 (0)