-
Notifications
You must be signed in to change notification settings - Fork 64
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
Include the Imgix.js generated srcset within react-imgix library #71
Comments
Hey @victorwhy. Thanks for the suggestion. Unfortunately, I haven't used AFAIK |
@frederickfogerty hi Frederick! thanks for responding. But yeah, i did notice it did a bit with srcset, but i'm looking for something a bit more granular. for example, if you use @jayeb pointed me here: FYI https://github.com/imgix/imgix.js/blob/master/src/targetWidths.js |
Just to be clear, the benefit from having all those srcsets, is that when the image is server rendered, it doesn't flicker for the user when the |
it's just much more granular and is able to grab a closer resolution sized image. i think currently This one will serve that, as well as an image that is ~100 pixels away from the actual size of the container, which could save a bunch of space. Does that make sense? |
I'm sorry, I still don't quite understand the benefit of the From the README of
I'm not sure if the "~100 pixels away" is in reference to this library. If it was, the reason behind that was to try reduce the number of cache misses for images that are not in fixed containers, thus creating a better experience for the user. You can disable/configure that behaviour by changing Maybe @paulstraw can weigh in here and try understand what I'm |
@frederickfogerty so yes, sorry, maybe I didn't make that clear. For us, a lot of the images we use we upload the full resolution. So a lot of the times they'll be like 2-3MB files, and even with compression theyre still big. So what So not only will it generate the different retina resolutions for that current size (dpr 2, dpr 3, that Does that make sense? It's more for images being fully responsive than anything else |
Does this make sense? I can't see any reason why the Imgix.js approach would produce different results to |
Maybe we could change our approach to using the in-built browser mechanisms, but for now it should be working fine. |
I don't see that responsiveness happening when I tested it out with the
yields which doesn't change regardless of what the width of your viewport is. there is no width parameter getting passed into imgix URL, so there's no way it's being responsive. and as a sanity check, you can see that the full img sizes are being downloaded. For example, when I use our custom srcset generator (which behaves a lot like This is all from a single url, with a base width and a max width passed in to generate the range. Unless I'm missing something, this is not the same at all. |
For what it's worth I ended up using imgix.js itself with React: import React from 'react'
import ReactDOM from 'react-dom'
class ImgixImg extends React.Component {
componentDidMount() {
this.setSrc(this.props.src)
}
componentWillReceiveProps(props) {
this.setSrc(props.src)
}
setSrc(src) {
const node = ReactDOM.findDOMNode(this)
node.setAttribute('ix-src', src)
// eslint-disable-next-line no-undef
imgix.init()
}
render() {
const {src, ...props} = this.props
return (<img alt="" {...props}/>)
}
}
export default ImgixImg |
This will be fixed in the next major version, v8. |
Imgix.js
is great at what it does, unfortunately due to the nature of the html being generated after the DOM is loaded, there is always a risk of a flicker for the user.I was looking into using this library instead to create responsive images, but noticed that the fancy srcset generation that
Imgix.js
does isn't part of this library.It'd be great if we can have it generate that
srcset
list here as well :)The text was updated successfully, but these errors were encountered: