You need to change height()
to offset().height
:
$('body').prepend('<div id="overlay" style="display: none;"></div>');
$('#overlay').fadeIn();
$('body').prepend('<div id="content" style="display: none;"><img class="photo" src="images/file.jpg" /></div>');
$(".photo").load(function(){
var h_image = $(this).offset().height-70;
var h_screen= $(window).height()-70;
if (h_image> h_screen) {
$(this).height(s_screen);
}
else {
$(this).height(h_image);
}
$('#content').fadeIn();
});