Web design, programming, graphics, and pretty much anything else I care about.

WebFM icons

WebFM uses multiple methods for determining what type of file it is dealing with, and thus, what icon to display. When inserting a file into the database it used the php function mime_get_content to determine the type of file. If this function does not exist WebFM uses its own function to determine the mime type. This function is in the webfm_mime_types.inc file. Basically, it just goes by the file extension.

When the webfm_nodeapi is called it eventually gets to a function that it uses to determine what icon to display. This function, _webfm_get_icon($ext), just has a switch that it uses to assign an icon file based on a string it has been given. (If any types/icons needed to be added, they have to be added here.) When WebFM goes through the motions of retrieving the file records from the database it dumps the information into a class it created called webfm_fdesc. This info includes name, title, date, description, etc. Built into this data type is a construct for determining various bits of information, one being the file extension. This extension is sent to the get_icon function to retrieve the correct icon. WebFM is mostly just relying on the file extension to determine what icon to use. A lot of the code seems to be there "just in case" or if someone calls the functions outside of WebFM. Maybe from a custom module or theme.

The icons that appear in the AJAX directory listing is a different story. These icons are determined inside the webfm.js javascript file in the js directory of webfm. Inside this file is the following: (It has been shortened here)

Webfm.icons = {
epdf:"pdf.gif", ephp:"php.gif", ephps:"php.gif", ephp4:"php.gif", ephp5:"php.gif", eswf:"swf.gif",
eai:"ai.gif", eskp:"skp.gif", emov:"qt.gif", epps:"pps.gif", eppt:"pp.gifs", emp4:"mpeg4.png", erm:"real.png", emov:"qt.gif"
};

Also, in the javascript file is the following line:

var icon = this.iconDir + '/' + ((Webfm.icons["e" + ext]) ? Webfm.icons["e" + ext] : "f");

Which is located in:

Webfm.filerow.prototype.getIconByExt = function() {

If a file type not in the list is needed it must be added. For example, epsd:"psd.png". NOTE: This javascript code originally had no extensions in the Webfm.icons declaration, and the end of the "var icon" line had "+ .gif". The gif extension was hard coded. This was modified so that other file types could be used. If WebFM is updated, this will likely need to be changed again.