Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

detecting image size

Status
Not open for further replies.

FesterSXS

Programmer
Joined
Feb 4, 2002
Messages
2,196
Location
GB
I have an ASP page which generates flat HTML from content in a database. Some of this content is paths to images. Because I dont have the actual image dimensions in the database, I am using Javascript in the flat 'generated' HTML pages to detect the image dimensions and then using these dimensions in the <IMG> tag.

Code:
<SCRIPT LANGUAGE='JAVASCRIPT'>
var Img=new Image;
Img.src='[URL unfurl="true"]http://myserver.com/images/mypicture.jpg';[/URL]
var iWidth=Img.width; 
var iHeight=Img.height;
</SCRIPT>

<SCRIPT LANGUAGE='JAVASCRIPT'>
document.write('<IMG SRC=[URL unfurl="true"]http://myserver.com/images/mypicture.jpg[/URL] WIDTH='+iWidth+' HEIGHT='+iHeight+' BORDER=0 ALT=&quot;My picture&quot; ALIGN=RIGHT>');</SCRIPT>

The problem I am having is this...

If I generate a page and then view it and decide the image is the wrong shape then I may well go into Photoshop and crop the image and reupload it. When I go back into the browser and view the page, the image is updated but is keeping the dimensions of its previous version.

How can I get the dimensions of the image to be redetected from fresh every time??

Please help this is driving me crazy!
Tony
reddot.gif WIDTH=400 HEIGHT=2 VSPACE=3

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top