Revert D14425373: [react-native][PR] [iOS] Remove explicitly add png file extension when load local image

Differential Revision:
D14425373

Original commit changeset: 3cc06c9a3d68

fbshipit-source-id: eef2ee9a459c35dcb30e0c023eb24854529149be
This commit is contained in:
Valentin Shergin
2019-03-20 14:37:46 -07:00
committed by Facebook Github Bot
parent b3c74967ca
commit 95b05c0d82
2 changed files with 8 additions and 0 deletions

View File

@@ -380,6 +380,11 @@ static UIImage *RCTResizeImageIfNeeded(UIImage *image,
[NSURLProtocol setProperty:@"RCTImageLoader"
forKey:@"trackingName"
inRequest:mutableRequest];
// Add missing png extension
if (request.URL.fileURL && request.URL.pathExtension.length == 0) {
mutableRequest.URL = [request.URL URLByAppendingPathExtension:@"png"];
}
if (_redirectDelegate != nil) {
mutableRequest.URL = [_redirectDelegate redirectAssetsURL:mutableRequest.URL];
}

View File

@@ -711,6 +711,9 @@ UIImage *__nullable RCTImageFromLocalAssetURL(NSURL *imageURL)
if (!image) {
// Attempt to load from the file system
NSString *filePath = [NSString stringWithUTF8String:[imageURL fileSystemRepresentation]];
if (filePath.pathExtension.length == 0) {
filePath = [filePath stringByAppendingPathExtension:@"png"];
}
image = [UIImage imageWithContentsOfFile:filePath];
}