The best way I think is to have either a boolean in the database that says there is a picture, or a field that holds the picture's filename. Either way you'll know if there's a picture or not before trying to display it.
You can write a recursive script with the fileexist function to populate this data first... In the end, this is the best way. IMO. > 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 sor ted > using their 3 leftmost character). i.e, Product_id # 303921 will go to th e > dir: \303\ > > First option: using CF: > <img src="<cfif > FileExists("#DirMap#\#left(Product_id,3)#\#Product_id#.jpg">#left(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="Lo ngList"> > > <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, templa te > was finished in 0 seconds. > > ______________________________________________________________________ Dedicated Windows 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=coldfusiona FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists