Skip to content

Commit

Permalink
Pass actual loaded image size to load (iOS).
Browse files Browse the repository at this point in the history
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 ced1513
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Libraries/Image/RCTImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit ced1513

Please sign in to comment.