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

[Image] Fetch different images depending on screen scale #1201

Closed
ide opened this issue May 8, 2015 · 9 comments
Closed

[Image] Fetch different images depending on screen scale #1201

ide opened this issue May 8, 2015 · 9 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@ide
Copy link
Contributor

ide commented May 8, 2015

Being able to fetch different resolution images depending on the device is good for all the reasons UIKit natively supports @#x, plus saving bandwidth. Something like srcset seems roughly right, and the code could look like:

<Image
  sourceSet={{
    2: {uri: 'http://example.com/image.php?w=200&h=200'}
    3: {uri: 'http://example.com/image.php?w=300&h=300'} 
  }}
/>

cc @vjeux you've probably thought about this

@vjeux
Copy link
Contributor

vjeux commented May 8, 2015

I'd like for it to be as transparent as possible, you should have an "image" object and send it to the source attribute and should be good to go. I like the idea but imo it should not be a different attribute.

@vjeux
Copy link
Contributor

vjeux commented May 8, 2015

cc @frantic: what is the current format you implement for handling 1x, 2x and 3x?

@ide
Copy link
Contributor Author

ide commented May 8, 2015

source={multiSourceObject} is OK too if it supports multiple URLs.

@frantic
Copy link
Contributor

frantic commented May 8, 2015

We currently do this for static images, because packager tells us what scales are available. We can do this for server side images as well, but we need information about what images are there on server.

Btw besides 1x, 2x and 3x we are going to support any scale, including 1.5x etc (Android will use that)

@bakso
Copy link

bakso commented May 9, 2015

Watch

@ide
Copy link
Contributor Author

ide commented May 9, 2015

@iostalk please use the Subscribe button on the right of the page

@brentvatne brentvatne changed the title Fetch different images depending on screen scale [Image] Fetch different images depending on screen scale May 30, 2015
@paramaggarwal
Copy link
Contributor

I feel it would be simpler if this resolution based image URL handling was done at a layer above React itself. This probably does not belong in the core. The application can decide what should be the correct image URL for the right resolution and then set source.uri.

@ccheever
Copy link
Contributor

I think this could probably be closed -- at least for now -- because https://github.com/exponentjs/react-native-responsive-image handles this nicely at the application layer (as @paramaggarwal suggested) with an interface like @ide described.

It might make sense to eventually migrate this to core if people are happy with the approach and using it becomes an agreed upon best practice.

@ide
Copy link
Contributor Author

ide commented Jul 15, 2015

thanks for the reminder. ResponsiveImage has been working well so far. npm packages ftw!

@ide ide closed this as completed Jul 15, 2015
@facebook facebook locked as resolved and limited conversation to collaborators Jul 15, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

7 participants