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

Add support similar to srcset to overcome resolution switching problem #27

Open
jeznag opened this issue Nov 3, 2017 · 5 comments
Open

Comments

@jeznag
Copy link
Contributor

jeznag commented Nov 3, 2017

I currently have this HTML to cater for retina devices:
<img src="assets/images/continuous-improvement.png" srcset="assets/images/continuous-improvement.png 1x, assets/images/infographic@2x.png 2x" alt="" />

Is there any way to achieve the same result with progressively?

@thinker3197
Copy link
Owner

thinker3197 commented Nov 4, 2017

Yes, you can use the data-progressive-sm attribute for loading lower resolution/quality image on smaller devices. For example, your markup would look similar to this

<figure class="progressive">
  <img class="progressive__img progressive--not-loaded" data-progressive="assets/images/infographic@2x.png" data-progressive-sm="assets/images/continuous-improvement.png" src="assets/images/continuous-improvement-lowly.png">
</figure>

Ps, Make sure you set proper break point value so that the non-retina image loads on devices with width > 600 and < 1500.

@jeznag
Copy link
Contributor Author

jeznag commented Nov 4, 2017

@thinker3197 It's not about the viewport width, it's about the device pixel ratio. With
<img src="assets/images/continuous-improvement.png" srcset="assets/images/continuous-improvement.png 1x, assets/images/infographic@2x.png 2x" alt="" />

It uses extra high res version of the image at high DPI and normal res at normal DPI.

if (window.devicePixelRatio >= 2) {
// retina display
} else {
// standard display
}

Retina displays can be on large screens so a viewport check is not appropriate.

@thinker3197
Copy link
Owner

Agreed, my bad I didn't understood it first. At the moment progressively doesn't support a similar functionality as srcset for higher resolution devices.

@jeznag
Copy link
Contributor Author

jeznag commented Nov 4, 2017

No worries. I'll have a go at a feature enhancement PR next week.

@thinker3197 thinker3197 changed the title Is there any way to set a different image for retina displays? Add support similar to srcset to overcome resolution switching problem Nov 4, 2017
@thinker3197 thinker3197 reopened this Nov 4, 2017
@hektorloto
Copy link

Actualmente tengo este HTML para atender dispositivos de retina: <img src="assets/images/continuous-improvement.png" srcset="assets/images/continuous-improvement.png 1x, assets/images/infographic@2x.png 2x" alt="" />

¿Hay alguna forma de lograr el mismo resultado progresivamente?

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

No branches or pull requests

3 participants