Forum Moderators: open

Message Too Old, No Replies

automatically resize images

         

xpurtwitness

1:14 am on Jan 28, 2004 (gmt 0)

10+ Year Member



I am hoping to find that there is a method to automatically fit images (most often shrinking) to the window they are displayed in. A good example is the Yahoo! Groups file section. When I click an image from that list, the new window is opened, and the image is dynamically sized as I adjusted the width and height of the window. I would like to preserve the size of the images for the quality if they are to be printed, but don't want folks to have to scroll to see the whole thing. Any ideas, guys? Much obliged.

RonPK

1:15 pm on Jan 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Let's start with something simple: how about <img src="my.jpg" width="100%">?
Or does the image have to resized when the user resizes the window?

xpurtwitness

10:23 pm on Jan 29, 2004 (gmt 0)

10+ Year Member



Yes, exactly. I don't believe we are allowed to list our site addresses here, so I can't really show you the example. However, the basic idea is this:

Frame 1 (Menu)
Frame 2 (Thumbnails)
Clicking on thumbnails loads that one picture into Frame 2, which is too small to accomodate the largest of the full-size pics. However, this window is dynamicly sized...I think my frames are set at width="150,*" or something. So, however large the frame appears, the pic should be fitted accordingly. And if they shrink their browser down, I would like the pic to snap to size as well.

ORBiTrus

2:14 am on Jan 30, 2004 (gmt 0)

10+ Year Member



Wouldn't a <img style='width:100%;height:100%'> do that?

Thus, you could say... onLoad find window width, window height. Get the aspect, if height>width, aspect width, otherwise aspect height. Knowing the width and height, set style.width to the window width and style.height to the window height. (Replace the appropriate with the aspect value).

Note: when I say aspect, I mean the aspect ratio of the image.