Forum Moderators: not2easy

Message Too Old, No Replies

Control image size - but just one attribute?

How to control image sizes that could be of any ratio

         

Etsian

10:15 pm on Apr 16, 2008 (gmt 0)

10+ Year Member



Hi there, I have a site that syndicates my artist friends' blogs. (That might sound kind of spammy, but I swear its not! I've put tons of work into it!)

Anyhow, once in awhile someone obviously has a blog post where they are hot linking to an image that is 5000 pixels wide but specifying something like "width=10%"

However when this pulls into my site, the style sheet for my site trumps whatever formatting they did.

(You're probably all like DUH)

So anyway, I can't just specify a limit that all images be, say, 400x200, because who knows what the original ratio is ... shrinking a 500x200 original image to 400x200 would of course make it look wonky.

So is there a bit of CSS I can use to just make sure that no images are more than 400 pix wide?

Thank you!
amanda

swa66

10:25 pm on Apr 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome Etsian

is there a bit of CSS I can use to just make sure that no images are more than 400 pix wide?

img {max-width:400px} 

comes to mind, but it might not be what you seek.

To get that to work in IE, you need to use some wacky expression. The IE crafters forgot to support max-width ... . Something like:

img {width: expression((documentElement.clientWidth > 400) ? "400px" : "auto" );}

Drop it in a IE only conditional comment to prevent problems down the road.

Etsian

1:03 am on Apr 17, 2008 (gmt 0)

10+ Year Member



People use IE? ;-)

Thank you, I will try that first.

Etsian

2:54 am on Apr 17, 2008 (gmt 0)

10+ Year Member



That seemed to work pretty well! There is one photo I found that it didn't shrink, but as long as it works most of the time, that's fine by me. Thanks again