jQuery.fn.imageAutoSize = function(width,height)
{
	$(this).find("img").each(function(){
        var image = $(this);
		if(image.width()>image.height()){
			if(image.width()>width){
				
				image.width(width);
			}
			
		}else{
			if(image.height()>height){
				image.height(height);
			}
		}
	})
}
