Please sign in to comment.
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
- Loading branch information...
Showing with 191 additions and 27 deletions.