Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request : getSizeWithHeaders #97

Open
jsellam opened this issue Nov 27, 2019 · 3 comments
Open

feature request : getSizeWithHeaders #97

jsellam opened this issue Nov 27, 2019 · 3 comments
Labels

Comments

@jsellam
Copy link

jsellam commented Nov 27, 2019

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.

@sunkibaek
Copy link
Contributor

@jsellam

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.

Inversion of Control

You can also send a PR if you are available for the task!

Thanks!

@jsellam
Copy link
Author

jsellam commented Nov 29, 2019

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.

@sunkibaek
Copy link
Contributor

Yeah, that's right. Then, inside of FitImage it will either use the passed prop or the default logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants