Display random image
I'm in the process of making some new banners for the top of the blog and want one to show up randomly. I did this on a site I made for the Anime Group at college. So I found that code first
<cfset num = randrange(1,x)>
<cfoutput>
<img src="anime#num#.jpg">
</cfoutput>
count.cfm
WTF, did I seriously have another file that I used just to tell me the number of banners I have? LOL, I suck. Well I'm not going to copy that crap to here. Here's some code that can be compressed to two lines and will randomly show any image in the given folder. Though I must admit, my old method was faster, since it wasn't lugging around a cfdirectory tag. But not like I'll have 10k banners and not like my blog gets any real traffic.
action="list"
directory="#ExpandPath('assets\banners')#"
name="dir"/>
<cfoutput>
<img src="assets/banners/#dir.name[RandRange(1,dir.recordcount)]#" alt="" />
</cfoutput>


http://www.miuaiga.com/index.cfm/2007/12/3/Show-a-...