mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add png extension only if file exist when load local image (#46971)
Summary: FIxes https://github.com/facebook/react-native/issues/46870. To avoid many breaking changes, I modified the logic to add the PNG extension only if the file exists. ## Changelog: [IOS] [FIXED] - Add png extension only if file exist when load local image Pull Request resolved: https://github.com/facebook/react-native/pull/46971 Test Plan: Demo in https://github.com/facebook/react-native/issues/46870 . Reviewed By: blakef Differential Revision: D65276409 Pulled By: cipolleschi fbshipit-source-id: 9e03a36b229f7c336632b5b76a92d9f749c59835
This commit is contained in:
1 parent
d7550293a2
commit
44f2a08371
1 file changed
+4
-1
@@ -477,7 +477,10 @@ static UIImage *RCTResizeImageIfNeeded(UIImage *image, CGSize size, CGFloat scal
|
||||
|
||||
// Add missing png extension
|
||||
if (request.URL.fileURL && request.URL.pathExtension.length == 0) {
|
||||
mutableRequest.URL = [request.URL URLByAppendingPathExtension:@"png"];
|
||||
NSURL *pngRequestURL = [request.URL URLByAppendingPathExtension:@"png"];
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath:pngRequestURL.path]) {
|
||||
mutableRequest.URL = pngRequestURL;
|
||||
}
|
||||
}
|
||||
if (_redirectDelegate != nil) {
|
||||
mutableRequest.URL = [_redirectDelegate redirectAssetsURL:mutableRequest.URL];
|
||||
|
||||
Reference in new issue
Block a user