Jason, Depends on whether you want to do the work server side or client side. Note that if you have several images on one page, the JavaScript method can get flaky. Also note the JS method doesn't work with NS4x.
That said, the JS method is very handy when you don't have physical access to the images. We use it extensively at http://BookCrossing.com. Since there are lots of images on each page, we found it was better to trigger a function on body load that loops through all the external images on the page, and replaces those that were not loaded. (Trying to do an onError for more than about 5 img tags on a page tends to lock up IE.) Here is the simple, but highly effective, script: <script language="JavaScript"><!-- var replacementImage = new Image(60,90); replacementImage.src = '/images/NoBookImageAvailable-60x90.gif'; function checkAllImages(){ for(i=0;i<document.images.length;i++){ //if image is from amazon, and is smaller than 30, //it didn't load and needs replaced if(document.images[i].src.indexOf("amazon.com")>=0 && parseInt(document.images[i].height)<=30) document.images[i].src=replacementImage.src } } //--> </script> </head> <body onLoad="checkAllImages();"> Hope this helps someone... if it does, you have to go register and release at least one book at http://BookCrossing.com now! :) Ron Hornbaker President/CTO . . . . . . . . . . . . http://humankindsystems.com . . . . . . . . . . . . w e c o d e. w e c a r e. . email tracking and routing made easy: http://answertrack.com > -----Original Message----- > From: Jason Davis [mailto:[EMAIL PROTECTED]] > Sent: Thursday, March 07, 2002 7:21 AM > To: CF-Talk > Subject: check for image existence > > > I have about 50,000 images that are displayed across the site. > I'm looking for the best mechanisem to replace a "non-exits" image > with a default file, and came across this two options. if anyone can > share his experince I'll appriciate it: > > (All 50,000 product photos are sorted in ~ 900 directories. > files are sorted > using their 3 leftmost character). i.e, Product_id # 303921 > will go to the > dir: \303\ > > First option: using CF: > <img src="<cfif > FileExists("#DirMap#\#left(Product_id,3)#\#Product_id#.jpg">#lef > t(Product_id > ,3)#/#Product_id#<cfelse>default</cfif>.jpg"> > > Second option: using javascript: > <img src="#left(Product_id,3)#/#Product_id#.jpg" > onError="this.src='default.jpg'"> > > Maybe this figure will help out: > > I did a small test on a 9000 files directory: > > <cfdirectory action="LIST" directory="E:\ProductItems\303" > name="LongList"> > > <cfoutput query="LongList"> > <cfif FileExists("E:\Syndicate\www.ynet.co.il\home\#NAME#")> > #NAME#<br> > </cfif> > </cfoutput> > > This went by in 4 seconds, where while eliminative the > FileExists, template > was finished in 0 seconds. ______________________________________________________________________ Why Share? Dedicated Win 2000 Server � PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation � $99/Month � Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/[email protected]/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

