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 srcSet or density sources #1595

Closed
RWOverdijk opened this issue Apr 21, 2020 · 4 comments
Closed

Image srcSet or density sources #1595

RWOverdijk opened this issue Apr 21, 2020 · 4 comments

Comments

@RWOverdijk
Copy link

RWOverdijk commented Apr 21, 2020

Is your feature request related to a problem? Please describe.

This is a feature request regarding images. Right now they don't seem to load the correct density causing images to not look sharp. I found another issue that's really old and the plugin that leads to has since dried up.

Describe a solution you'd like

At the very least it would be nice if I could just provide a srcSet as a workaround. Even better would be if that srcSet were to be created inside of the Image component.

I have the @2x and @3x images, they're just not being used on web.

Describe alternatives you've considered

I tried creating my own image component but it comes with a lot of challenges such as jsx not allowing me to use StyleSheet styles (meaning I'd have to inline all of my styles).

Update: to be clear, this works for me if I inline all the styles and write custom implementations for web and mobile (and forego the Animated.Image support and a couple of other things):

<img srcSet={`${images.someImagex2} 2x, ${images.someImagex3} 3x`} source={images.someImage} width={535} height={654} style={{ width: 535, height: 654 }} />

Additional context

I found this PR which was closed in favour of this PR which was then closed by this commit which just says "Requires bundler integration.".

It could be that what I'm really asking is for some documentation on this.

I am using expo, but to make sure I tried everything I first ejected and upgraded to "react-native-web": "^0.12.2", which was a pain because I had to change a ton of things for that. So please don't just close this 😅

@RWOverdijk
Copy link
Author

Update: I'm trying to work around this by requiring the densities myself, but this gives me a "compile error":

Unable to resolve module './splash@2x.png' from 'assets/images/index.js

The file is there. And it works on web. But on mobile this error shows up and I don't know what to do about it. I tried wrapping it in a conditional, putting it in a try catch block but no success.

@RWOverdijk
Copy link
Author

I'd like to bump this issue. Is there anything I can do to solve/work around this?

@nandorojo
Copy link
Contributor

Did you ever figure something out for srcSet? I'm looking for a way to use sizes and srcSet with large images.

@RWOverdijk
Copy link
Author

Nah, I just hacked my way around it and wrote specific code for web. Eventually I just stopped using the project altogether because the user experience wasn't quite there.

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

No branches or pull requests

2 participants