bbc / Imager.js

Responsive images while we wait for srcset to finish cooking
Apache License 2.0
3.84k stars 224 forks source link

Fixed the response image `width=0` bug when `data-width` is not set #83

Closed thom4parisot closed 10 years ago

thom4parisot commented 10 years ago

Example here: http://lab.gasteroprod.com/imager/ex01/

The container width has to be explicitly set to 100% for example.

Imager should at least pick 320 if the width is not properly picked up.

Props of @nhoizey

drwlrsn commented 10 years ago

This threw me for a loop yesterday. :(

e-chapin commented 10 years ago

This threw me for a loop as well.

thom4parisot commented 10 years ago

With this PR the image width attribute is set only when it's set.

This way the container is driving the image sizing, unless you really want to force it.

Let me know if that works for you, especially @nhoizey :-)

nhoizey commented 10 years ago

Seems to work well! \o/