Forum Moderators: open

Message Too Old, No Replies

Resizing a REMOTE Image

         

digitalv

5:16 pm on Aug 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ever been in a forum and someone links to a large picture that makes the text scroll horizontally? I'm trying to find a way to fight that - the problem is the images are remote, ie, never on my server so I can use a component to resize them.

Is there any way, through Javascript, that I can read the width and height of a remote image that's being displayed on a page and if it exceeds a certain width/height run some code to resize its appearance in the browser?

Or just a way to set a "max width" to an image in general?

digitalv

5:19 pm on Aug 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nevermind, found a CSS "max-width" property that does the trick.

RonPK

7:51 pm on Aug 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



max-width won't do much in IE. You might want to consider using a CSS expression to simulate max-width:

img#mypic {
max-width: 50px;
width: expression(this.clientWidth > 50? "50px" : "auto");
}