Page 1 of 1

Quick html question

Posted: Mon Jan 19, 2004 12:30 pm
by pinehead18
Is their a way in html to set the max height and width for an image. But if the image isn't that size it does not make it fit it? It just wont let it go past the max width and height?

Posted: Mon Jan 19, 2004 12:36 pm
by Roja
Sort of.

On the img tag itself, you can set height/width tags:

Code: Select all

<img src="somefile.png" width="100" height="100">
However, it doesnt PREVENT the image from being more than those dimensions - it simply uses a fairly crappy resize function to force it to fit into those dimensions for the display. (Meaning, the client still could be downloading a 1024x768 size image, but displaying it as 100x100.. much bandwidth loss).

It does prevent an image from breaking a pixel-perfect layout, but there are many (including me) that would argue that a pixel-perfect layout is inherently bad for a variety of reasons.

But thats how to use html to resize the image to a locked height/width. :)

Posted: Mon Jan 19, 2004 12:40 pm
by pinehead18
Yeah, thats what i have been doing. What i was wanting to accomplish is not lock the image unless it reaches that widht/height see what i mean?

Posted: Mon Jan 19, 2004 1:53 pm
by Roja
pinehead18 wrote:Yeah, thats what i have been doing. What i was wanting to accomplish is not lock the image unless it reaches that widht/height see what i mean?
Ah. Hmm. You could instead do..

Code: Select all

<table>
<td>
<tr height = "200px">
<img src="somefile.png" height="100%">
</tr>
</td>
</table>
I beleive that will allow the picture to be displayed up to 200px, but not above. Granted, I havent tested it, but .. I think the concept is sound to do what you are asking for.

I also think you could do the same with just css (and probably much better than the above hack), but I cant 'freehand' css just yet.. not that good at it yet.

Posted: Mon Jan 19, 2004 3:07 pm
by pinehead18
as you can tell i can barely free hand html lol so i think the above will work. I'll let you know how ti goes as soon as i put it in the sytem

Posted: Tue Jan 20, 2004 12:14 am
by pinehead18
<tr height = 50px><td align=center><img src=http://l.com/pics/$mainpic></tr></td>

That is what i have.. it dones't seem to make the pic go smaller..
Suggestions?

Posted: Tue Jan 20, 2004 1:07 am
by jtc970
<table>
<td align=center>
<tr height = "50px"><img src=http://l.com/pics/$mainpic>
</tr></td>
</table>

Posted: Tue Jan 20, 2004 11:00 am
by pinehead18
I set it to 10px to see if it would resize the image and it didn't.

Any other ideas?