﻿jQuery.fn.ImageAutoSize = function(width,height)//width:140 =X1 height:140 =Y1
{
    $("img",this).each(function()//X2,Y2
    {
        var image = $(this);
        if(image.width()>width)//if X2>140
        {
            image.width(width);//X2=140
            image.height(width/image.width()*image.height());//Y2=140/X2*Y1
        }
        if(image.height()>height)
        {
            image.height(height);
            image.width(height/image.height()*image.width());
        }
    });
}
