Return to Snippet

Revision: 14207
at May 24, 2009 05:42 by philokezzar


Initial Code
function ResizeImage(image, maxwidth, maxheight)
{
    if (image.className == "Thumbnail")
    {
        w = image.width;
        h = image.height;
                
        if( w == 0 || h == 0 )
        {
            image.width = maxwidth;
            image.height = maxheight;
        }
        else if (w > h)
        {
            if (w > maxwidth) image.width = maxwidth;
        }
        else
        {
            if (h > maxheight) image.height = maxheight;
        }
                
        image.className = "ScaledThumbnail";
    }
}

Initial URL

                                

Initial Description

                                

Initial Title
Javascript dynamic image resizing

Initial Tags
javascript, resize, image, textmate

Initial Language
Other