mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Add Image#getSize for Android
Summary: I've implemented the getSize method on Image for Android. **Test plan (required)** The result in the UIExample app can be seen here:  Closes https://github.com/facebook/react-native/pull/7664 Differential Revision: D3331704 fbshipit-source-id: d784c861cbc653cd6b49310f4b5516c6583486ca
This commit is contained in:
committed by
Facebook Github Bot 1
parent
fb5d0ff587
commit
c1558bc7db
@@ -113,6 +113,21 @@ var Image = React.createClass({
|
||||
|
||||
statics: {
|
||||
resizeMode: ImageResizeMode,
|
||||
|
||||
getSize(
|
||||
url: string,
|
||||
success: (width: number, height: number) => void,
|
||||
failure: (error: any) => void,
|
||||
) {
|
||||
return ImageLoader.getSize(url)
|
||||
.then(function(sizes) {
|
||||
success(sizes.width, sizes.height);
|
||||
})
|
||||
.catch(failure || function() {
|
||||
console.warn('Failed to get size for image: ' + url);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Prefetches a remote image for later use by downloading it to the disk
|
||||
* cache
|
||||
|
||||
Reference in New Issue
Block a user