From 4838d5921f887d7d5b48e32598d309d8c7b66bf6 Mon Sep 17 00:00:00 2001 From: Colin Ramsay Date: Wed, 1 Apr 2015 10:50:00 -0700 Subject: [PATCH] Add support for web-style data-uris Summary: This implements base64-encoded data-uris for the Image component. Closes https://github.com/facebook/react-native/pull/576 Github Author: Colin Ramsay Test Plan: Imported from GitHub, without a `Test Plan:` line. --- React/Base/RCTConvert.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/React/Base/RCTConvert.m b/React/Base/RCTConvert.m index 10a8fbd54..3f8057d61 100644 --- a/React/Base/RCTConvert.m +++ b/React/Base/RCTConvert.m @@ -547,7 +547,11 @@ RCT_CGSTRUCT_CONVERTER(CGAffineTransform, (@[ UIImage *image = nil; NSString *path = json; - if ([path isAbsolutePath]) { + if ([path hasPrefix:@"data:"]) { + NSURL *url = [NSURL URLWithString:path]; + NSData *imageData = [NSData dataWithContentsOfURL:url]; + image = [UIImage imageWithData:imageData]; + } else if ([path isAbsolutePath]) { image = [UIImage imageWithContentsOfFile:path]; } else { image = [UIImage imageNamed:path];