From ced1513b62f6c4a75447cd0b22f44f898b737560 Mon Sep 17 00:00:00 2001 From: Shir Levkowitz Date: Thu, 20 Jul 2017 02:49:35 -0700 Subject: [PATCH] Pass actual loaded image size to load (iOS). Summary: Motivation: The JavaScript image component's onLoad callback optionally accepts dimensions width and height, allowing the parent of the image to obtain the native size (without an extra bridge call). It was found that the dimensions passed into this callback on iOS are frequently (0,0), not the true native dimensions. This change ensures that the image's dimensions are passed to the callback. (Examination of the initializer for RCTImageSource, + (RCTImageSource *)RCTImageSource:(id)json, indicates that not all code paths produce a size other than CGSizeZero.) Closes https://github.com/facebook/react-native/pull/15116 Differential Revision: D5460979 Pulled By: javache fbshipit-source-id: 2dca03c3aae974ef70e981039aa6a804b8e128c8 --- Libraries/Image/RCTImageView.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Libraries/Image/RCTImageView.m b/Libraries/Image/RCTImageView.m index 6387987e6..cbb3e4756 100644 --- a/Libraries/Image/RCTImageView.m +++ b/Libraries/Image/RCTImageView.m @@ -364,7 +364,8 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) } } else { if (self->_onLoad) { - self->_onLoad(onLoadParamsForSource(source)); + RCTImageSource *sourceLoaded = [source imageSourceWithSize:image.size scale:source.scale]; + self->_onLoad(onLoadParamsForSource(sourceLoaded)); } if (self->_onLoadEnd) { self->_onLoadEnd(nil);