div containing image height & width, from cache

div containing image height & width, from cache

Hi,
I have a div containing an image. The purpose of the div is to set the maximum size of the image both in width and in height.

The image is set with height: 100% & width: auto or height: auto & width: 100% depending if the image is in portrait or landscape mode.

This is all fine and dandy until cached images are encountered.

In both FF and Chrome, if the image is just loaded, a .height() & .width() on the images returns the correct numbers, but if the image is cached, both those functions return 0.

How can this be fixed? Anyone else see this issue?