react-native/Libraries/Image
Nick Lockwood 718cd7953f Added getImageSize method
Summary:
public

This diff adds a `getSize()` method to `Image` to retrieve the width and height of an image prior to displaying it. This is useful when working with images from uncontrolled sources, and has been a much-requested feature.

In order to retrieve the image dimensions, the image may first need to be loaded or downloaded, after which it will be cached. This means that in principle you could use this method to preload images, however it is not optimized for that purpose, and may in future be implemented in a way that does not fully load/download the image data.

A fully supported way to preload images will be provided in a future diff.

The API (separate success and failure callbacks) is far from ideal, but until we agree on a unified standard, this was the most conventional way I could think of to implement it. If it returned a promise or something similar, it would be unique among all such APIS in the framework.

Please note that this has been a long time coming, in part due to much bikeshedding about what the API should look like, so while it's not unlikely that the API may change in future, I think having *some* way to do this is better than waiting until we can define the "perfect" way.

Reviewed By: vjeux

Differential Revision: D2797365

fb-gh-sync-id: 11eb1b8547773b1f8be0bc55ddf6dfedebf7fc0a
2015-12-31 18:51:30 -08:00
..
RCTImage.xcodeproj Added RCTDataRequestHandler 2015-10-19 09:07:06 -07:00
__tests__ Load assets from same folder as JS bundle 2015-11-05 12:53:26 -08:00
AssetRegistry.js [ReactNative] Teach flow how to deal with images 2015-08-26 18:26:09 -08:00
GlobalImageStub.js Removed references to isStatic from the codebase 2015-10-13 06:44:30 -07:00
Image.android.js Make style property available in Image.android.js like Image.ios.js 2015-12-07 10:47:28 -08:00
Image.ios.js Added getImageSize method 2015-12-31 18:51:30 -08:00
ImageEditor.js Added JS wrappers for ImageStore and ImageEditor 2015-12-23 10:08:07 -08:00
ImageResizeMode.js Bugfix - Typos 2015-12-15 09:09:32 -08:00
ImageSource.js Fix flow errors 2015-12-31 07:48:29 -08:00
ImageStore.js Added JS wrappers for ImageStore and ImageEditor 2015-12-23 10:08:07 -08:00
ImageStylePropTypes.js Added ColorPropType 2015-12-23 10:08:38 -08:00
RCTGIFImageDecoder.h Added RCTDataRequestHandler 2015-10-19 09:07:06 -07:00
RCTGIFImageDecoder.m Replaced RCTSparseArray with NSDictionary 2015-11-14 10:28:28 -08:00
RCTImageEditingManager.h [React Native] open source ImageEditingManager native module 2015-07-29 15:57:48 -08:00
RCTImageEditingManager.m Added JS wrappers for ImageStore and ImageEditor 2015-12-23 10:08:07 -08:00
RCTImageLoader.h Added getImageSize method 2015-12-31 18:51:30 -08:00
RCTImageLoader.m Added getImageSize method 2015-12-31 18:51:30 -08:00
RCTImageStoreManager.h RTCImageStoreManager uses NSData instead of UIImage 2015-11-17 09:55:31 -08:00
RCTImageStoreManager.m Added JS wrappers for ImageStore and ImageEditor 2015-12-23 10:08:07 -08:00
RCTImageUtils.h Added getImageSize method 2015-12-31 18:51:30 -08:00
RCTImageUtils.m Added getImageSize method 2015-12-31 18:51:30 -08:00
RCTImageView.h Added RCTImageSource 2015-12-08 03:32:30 -08:00
RCTImageView.m Fixed image tinting 2015-12-10 09:09:30 -08:00
RCTImageViewManager.h Merged RCTNetworkImageView functionality into RCTStaticImage 2015-07-17 07:43:16 -08:00
RCTImageViewManager.m Added getImageSize method 2015-12-31 18:51:30 -08:00
RCTShadowVirtualImage.h Added RCTImageSource 2015-12-08 03:32:30 -08:00
RCTShadowVirtualImage.m Added RCTImageSource 2015-12-08 03:32:30 -08:00
RCTVirtualImageManager.h Implemented inline image support for <Text> 2015-10-08 11:56:25 -07:00
RCTVirtualImageManager.m Added RCTImageSource 2015-12-08 03:32:30 -08:00
RCTXCAssetImageLoader.h Unify XCAsset handling logic 2015-10-12 04:15:27 -07:00
RCTXCAssetImageLoader.m Improved threading for image loader 2015-10-20 05:02:23 -07:00
RelativeImageStub.js [ReactNative] Teach flow how to deal with images 2015-08-26 18:26:09 -08:00
resolveAssetSource.js Load assets from same folder as JS bundle 2015-11-05 12:53:26 -08:00