Jump to content

Image Loading


javascriptman19

Recommended Posts

If I do

 

 

<img id="IMAGE2" src="" style="max-width: 200px; max-height: 300px;">document.getElementById("IMAGE2").src = 'test.jpg';imgheight = document.getElementById("IMAGE2").offsetHeight;

 

 

on img's with max-width / max-height attributes not ones with fixed height/width....

 

sometimes i get 0 and sometimes i get a number...

 

then i noticed if i set the image... then set a timeout for 300 miliseconds then the offsetHeight always gives a number... can someone explain this to me? is the code going on before the image gets resized by the browser causing there to be no height to return resulting with the 0?

Link to comment
https://forums.phpfreaks.com/topic/212480-image-loading/
Share on other sites

I GOT IT!!!

 

with max/min height/widths... theres no pre-set height/width so u don't know it until the image fully downed/rendered... thats the problem...

 

i got a question though... as the image downloads does it render at the same time... or does it download in the background then render? and if so can u get the height/width settings if it downloaded but has rendered yet? even though its like a 1 second process

Link to comment
https://forums.phpfreaks.com/topic/212480-image-loading/#findComment-1107060
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.