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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

custom tag to show the right icon for a file extension

Status
Not open for further replies.

frank11

Programmer
Jul 15, 2007
2
CA
hi everyone... I'm wondering if anyone out there knows about a custom tag that will parse out the file extension for a give file and display the appropriate icon for it.

For example:
1. any txt, pdf, doc, rtf would show a document style graphic
2. any gif, bmp, jpg, jpeg, png would show a graphic style graphic

Thanks
 
If you have the graphic you want displayed, you could easily do this with a few lines of code.



Hope This Helps!

ECAR
ECAR Technologies

"My work is a game, a very serious game." - M.C. Escher
 
just make a simple structure

strIcons = structNew()

and populate it with document extensions and icon filenames

strIcons.doc = "doc.gif"
strIcons.txt = "doc.gif"
strIcons.rtf = "doc.gif"
strIcons.xls = "xls.gif"
strIcons.mpg = "video.gif"
strIcons.avi = "video.gif"


They when choosing an icon (in a function or tag to make it easy) check to see if you have an icon for that filetype, and dispplay it, or a default icon. Populate the icon structure from a database if you want.


<cfif structKeyExists(strIcons,fileExtension)>
<img src=....strIcons[fileExtension] />
</cfelse>
<img src=...genericblankicon.gif />
</cfif>

Kevin

Phase 1: Read the CFML Reference
Phase 2: ???
Phase 3: Profit!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top