feature request : getSizeWithHeaders
Opened this issue · 3 comments
Hi,
I'm using react-native-fit-image, it's a very usefull job. thx.
In my project I'm adding auth with token on our image provider. In your source code, you use Image.getSize to get the original image size.
Could you add getSizeWithHeaders https://facebook.github.io/react-native/docs/image#getsizewithheaders when the "source" prop contain and "headers" object and use getSizeWithHeaders in this case please ?
best regards,
Jérémie.
Hi Jérémie,
That seems definitely possible! But instead of having if-else
branch for that I might try to leave the option open to the API users as they do talk about in Inversion of Control principle.
You can also send a PR if you are available for the task!
Thanks!
Do you mean something like that :
const getImageSize = (source) => {
return () => new Promise((resolve, reject) => {
Image.getSizeWithHeaders(
source.uri,
source.headers,
(originalWidth, originalHeight) => {
resolve({originalWidth, originalHeight})
},
(e) => reject(e),
);
})
}
<ImageOpti getSizePromise={getImageSize(source)} source={source}/>
Jérémie.
Yeah, that's right. Then, inside of FitImage
it will either use the passed prop or the default logic.