maxSize for Image

admin

Administrator
Staff member
I know you can set the height and width of and image using the height and width tags. However, I have many different size images. I want to limit the height and width to fit on a page, but I don't want to blow up really tiny images. The images are being displayed in a loop (written in vb) that pulls them from a database, so I can't just set each images tags seperately.<br />
<br />
Any suggestions you may have will be greatly appreciated...<br />
<br />
Thanks<!--content-->If your img tags are hard coded in the database, I don't think there is anything you can do. You will have to make the width value a variable so you can change it as needed.<!--content-->The image tags are not in the database, just the images...<br />
<br />
Here is the code:<br />
<%Do While Not RS1.EOF%><br />
<br />
<img src =http://www.htmlforums.com/archive/index.php/"u_ShowImg.asp?d1='<%=RS1("d1")%>'" id="showimg"><br />
<br />
<%RS1.moveNext<br />
Loop<br />
<br />
Ideally I would like to set maxHieght, maxWidth values, but that doesn't seem possible...<br />
<br />
Is there a way to check the size of the image and then reset the height and width if the size is too big? That way I wouldn't be blowing up my small images.<!--content-->I'm sorry but I don't know VB at all. If you can use VB to somehow grab the screen resolution and place that in a variable, and if you can store the value of the width of the image in the DB, then you could do a simple comparison before printing the image tag, and assign the width value at that time. <br />
<br />
Using a generic example:<br />
<br />
<br />
if ($img_width >= $screen_res) {<br />
$img_width = ($screen_res - 40);<br />
}<br />
<br />
print "<img src=http://www.htmlforums.com/archive/index.php/$theimage width=$img_width>"<br />
<br />
<br />
if you can't use VB to get the screen resolution, you maybe can do the whole thing with javascript, but once again, I don't know javascripting.....<!--content-->
 
Back
Top