This question has been asked a hundred times, but I haven't been able to find the perfect solution, -yet.

I have a page where i load pictures dynamically when user clicks <- or -> buttons, with some simple jQuery.
$.post('/v2/_ajax/loadImage.php', { 
event_id: event_id, image_id: image_id,
}, function(data) {
What i need, is a way for the picture to be resized, if it exceeds 900px in width, OR if the height is bigger than the browser - 60px.

I have tried the jQuery plugin MaxImage ( but it has some very strange behaviour, and it only resizes when you resize the browser, not when the image is loaded.

Is there any good solution?