I have images of various dimensions and I wish to lazyload them. For example: (without lazyload)
<img src='200x200.jpg' />
(with lazyload)
<img class='lazy' src='16x16loading.gif' data-original='200x200.jpg' />
<script type='text/javascript'>$('img.lazy').lazyload();</script>
Before they are successfully loaded, I want to display a loading gif in its place. However I also want its dimension to settle to the desired dimension prior to the image finishing loading, but NOT the gif dimension itself as the low-definition gif will be quite ugly with a zoom.
So translating the above into points:
- adding
width=200px
will stretch the rotating gif into a very ugly big one. - not doing so will let the rotating gif occupy ONLY 16x16 of whitespace until 200x200.jpg is loaded.
- Making a 16x16loading.gif into actually a 200x200.gif (according to my own noob attempt), increased its file-size by 770% from 1.7kb to 14.8kb.
So is there a way to show a rotating loading gif in its original dimension but let it take up as much whitespace as I like, possibly with CSS?