BoulderBum
Programmer
I want to have a bunch of thumbnails, and I'd like to confine their dimensions to the size of a table cell. The current experimental function I use is this:
I call this function in the onload event handler of the image BUT onload doesn't fire until the entire image is loaded, so I get giant pictures and eventually little thumbnails (which sucks).
How can I set the image size BEFORE the images get displayed?
Code:
var maxSize = 30;
function ResizeThumbNail( thumb )
{
var proportion = ( thumb.width > thumb.height ? thumb.width / maxSize : thumb.height / maxSize );
var newHeight = thumb.height / proportion;
var newWidth = thumb.width / proportion;
thumb.height = newHeight;
thumb.width = newWidth;
}
I call this function in the onload event handler of the image BUT onload doesn't fire until the entire image is loaded, so I get giant pictures and eventually little thumbnails (which sucks).
How can I set the image size BEFORE the images get displayed?