[jQuery] Loading images using .load() - can't access img height?

[jQuery] Loading images using .load() - can't access img height?


Hi,
I'm loading an HTML img tag into a div via the .load() function. What
I would like to do is animate the container div to the height of the
new image. The script I have works OK sometimes but on seemingly
random occasions the code cannot access the height of the image - it
returns 0 or 18.
The code is below. The loadImage() function is called whenever a thumb
is clicked on. My aim is to get the height of the new image and then
fade it in when it has been loaded.
$(document).ready(function() {
    $('.thumb').livequery('click', function(event) {
        loadImage($(this));
        return false;
    });
});
function loadImage(obj) {
    $('.imgMain img').fadeOut('fast', function() {
        $('.imgMain img').remove();
        $('.imgMain').load( '/includes/showimage.asp?img=' + $
(obj).attr('href'), {limit: 90}, function() {
            // height here is not known
            $('.imgMain img').hide();
            $('.imgMain').animate({'height': $('.imgMain img').height() +
'px'}, 'slow', function() {
                    $('.imgMain img').fadeIn('slow');
                    // height here is known
                });
            });
    });
}
Many thanks,
Pete