Permalink
Browse files

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 #15116

Differential Revision: D5460979

Pulled By: javache

fbshipit-source-id: 2dca03c3aae974ef70e981039aa6a804b8e128c8
  • Loading branch information...
Shir Levkowitz authored and facebook-github-bot committed Jul 20, 2017
1 parent bc0717c commit ced1513b62f6c4a75447cd0b22f44f898b737560
Showing with 2 additions and 1 deletion.
  1. +2 −1 Libraries/Image/RCTImageView.m
@@ -364,7 +364,8 @@ - (void)imageLoaderLoadedImage:(UIImage *)loadedImage error:(NSError *)error for
}
} 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);

0 comments on commit ced1513

Please sign in to comment.