The second option has to be better, since you're calling FileExists for all
images whether they are there or not whereas the javascript error only
triggers when there isn't one. 


-----Original Message-----
From: Jason Davis [mailto:[EMAIL PROTECTED]]
Sent: 07 March 2002 13:21
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">#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="Long
List">

<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.


______________________________________________________________________
Get Your Own 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=coldfusionb
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

Reply via email to