PDA

View Full Version : Image handling based on orientation


tigrou1976
12-11-2005, 05:23 PM
Hello and thanks in advance,

Here is the problem: I have a dynamic page that shows thumbnails. you can see an example at: http://joselino.com/gallery_pics.cfm?groupID=4

As you can see the images are set to: <img src="mydynamic.jpg" width="150"> If I set the height too I will get a distorted image if the image is another orientation than the set value, like horizontal.

What I need is to have all the photos the same size whether they are vertical OR horizontal.

My javascript idea is this: Make a script that loads in the header that preloads all the images, determines thier orientation.
ie: if image1.height > image1.width set image.orientation vertical

Then in the body put a conditional write script saying:

if image1.orientation = vertical write <img src="image1.jpg" height="150">
if image1.orientation = horizontal write <img src="image1.jpg" width="150">

If the basic code exists I can populate the code dynamically.

Or, is there some ilayer, object or div technique I should use that is simpler?

Thanks!

hyperbole
12-11-2005, 05:32 PM
Why not just leave hte dimensions off all together and let the browser get the image size from the image?



.

tigrou1976
12-15-2005, 07:23 AM
Why not just leave hte dimensions off all together and let the browser get the image size from the image?



.


Well, I need more control over the images depending on the page. And I don't want to have to resize all the images if I have a design change. I did find a great answer to my problem here (http://www.sitepoint.com/forums/showthread.php?t=325527)
It is a powerful tool.