I use Unveil.js to lazy load images. To save time/space, I use a base64 placeholder image:
Код: Выделить всё
[img]data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7[/img]
So if the image tag above is inside of a
Код: Выделить всё
Код: Выделить всё
Код: Выделить всё
Код: Выделить всё
max-width: 100%; height: auto;However, the data URI image always remains square, regardless of width/height attributes in the
Код: Выделить всё
I set up a quick fiddle to demonstrate the sizing differences (without Unveil.js): http://jsfiddle.net/silb3r/7bnfqkko/1/
And one with Unveil.js: http://jsfiddle.net/silb3r/2eff5thm/ (you may need to manually throttle your connection to see the issue)
Is anyone familiar with a way to ensure that the data URI maintains the aspect ratio of the original image? Preferably without adding more jQuery, but I am open to anything.
Thank you for any suggestions.
Источник: https://stackoverflow.com/questions/287 ... uto-height
Мобильная версия