...

View Full Version : CSS Image resizing



lozhowlett
09-29-2007, 04:09 PM
Hi Everyone,

I have some images which are uploaded to my server by a third party daily. Now these could be in a range of different sizes, so I need to fix the max-width element. Now I know this doesnt work in IE, so I was told I could use...



.imggallery {
max-width: 125px;
width:expression(this.width > 125 ? "125px" : this.width);
}

.mainpic {
max-width: 350px;
width:expression(this.width > 350 ? "350px" : this.width);
}


However in FireFox this works great, but in IE the images dont appear?

This is how i reference the images...


<img src="<%=varImageDir%><%=varP%>" alt="" border="0" class="mainpic" name="mainpic">

Thanks for any help in advance.

Loz

rmedek
09-29-2007, 04:32 PM
However in FireFox this works great, but in IE the images dont appear?
:confused: I always thought expressions were an IE only thing? Either way, since you're using a CMS of some sort, is there a reason why you don't implement the image resizing on the server end?

For these sorts of situations I tend to use a PHP script called phpthumb() (http://phpthumb.sourceforge.net/); it's great at dynamically resizing elements and caches the results as well. You need some sort of image library installed on the server and, of course, PHP. Maybe this will work for you…

lozhowlett
09-29-2007, 04:37 PM
Hi,

Yes there is - because the images are uploaded directly from some software at the clients, so I have no scripting control over the upload, plus there are about 1000 fotos daily, so would be a lot of processing and bandwidth doing it server side.

I dont use PHP, i code in ASP. But thank you -

The only solution I want to use in CSS or javascript for this element.

Many thanks.

lozhowlett
10-01-2007, 01:24 PM
can anyone think of a solution for this one? really struggling! thank you.

vtjustinb
10-01-2007, 04:04 PM
Hi,

Yes there is - because the images are uploaded directly from some software at the clients, so I have no scripting control over the upload, plus there are about 1000 fotos daily, so would be a lot of processing and bandwidth doing it server side.

I dont use PHP, i code in ASP. But thank you -

The only solution I want to use in CSS or javascript for this element.

Many thanks.

But if you only control the width of the image with CSS or HTML the client has to download the entire image even if it's displayed as a thumbnail. This could cripple the page for users with a slow connection, especially if the gallery contains lots of large images.

Also if bandwidth is a concern then generating thumbnails and caching is definitely what you want. Not to mention doing this server-side gives you access to the dimensions of the image to noodle with. 1000 photographs isn't a lot of server load, even if it had to perform that concurrently. Your engine should be able to handle it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum