secretsquirrel
Programmer
hi guys,
i have a mysql database from which i'm retrieving paths to image files to display in my page (eg. 'images/myPhoto.jpg'). i'm having a bit of trouble resizing the images because some of them are portrait and some are landscape.
i've put together a bit of javascript which compares the width and height of the image and then resizes it accordingly...
if (image.width > image.height)
{
image.width = "200";
} else {
image.height = "200";
}
...like this.
the problem is that when the page loads, the images are displayed and *then* resized, so the page loading looks awful as the images appear at full size and then shrink to the size i want.
i've tried setting the images' display property to 'none', resizing them then setting the display to 'block', but with the display set to 'none' the browser thinks the images are 0 pixels by 0 pixels and as such, doesn't display them correctly.
can anyone suggest a way of obtaining the image dimensions *before* they're put into the page?
thanks in advance,
ss...
i have a mysql database from which i'm retrieving paths to image files to display in my page (eg. 'images/myPhoto.jpg'). i'm having a bit of trouble resizing the images because some of them are portrait and some are landscape.
i've put together a bit of javascript which compares the width and height of the image and then resizes it accordingly...
if (image.width > image.height)
{
image.width = "200";
} else {
image.height = "200";
}
...like this.
the problem is that when the page loads, the images are displayed and *then* resized, so the page loading looks awful as the images appear at full size and then shrink to the size i want.
i've tried setting the images' display property to 'none', resizing them then setting the display to 'block', but with the display set to 'none' the browser thinks the images are 0 pixels by 0 pixels and as such, doesn't display them correctly.
can anyone suggest a way of obtaining the image dimensions *before* they're put into the page?
thanks in advance,
ss...