Hi, decided to post my first official plugin here. It’s a small helper function that we’ve used in a couple of projects and found that it cleaned up the code a bit and saved us a couple of minutes in each project.
“File Extension Icon” returns an icon or the file type as text for a specific file, based on the file’s extension.
Usage
The plugin returns an icon (or the type as text) for a specific file based on the file extension (ie. .gif, .jpg, .pdf). The default parameters works great with the Silk icons by FamFamFam but you can customize the icons any way you want.
Basic usage:
{exp:file_ext_icon width="10" height="10"}http://www.somesite.com/some_file.jpg{/exp:file_ext_icon}
Returns:
/images/icons/jpg.png
Making use of the print_type parameter (to add CSS class in this case):
<li class="{exp:file_ext_icon print_type='yes'}/some_file.jpg{/exp:file_ext_icon}">Text</li>
Returns:
<li class="jpg">Text</li>
Parameters (examples):
Download plugin:
http://republiclabs.com/expressionengine/file_ext_icon/
The default parameters works without parameters with the Silk icons as far as size (16x16px) and format (png), but you need to rename the icon files you wish to use.
All icons starting with “page_” are usually good for file extension icons and I know that many use the page_white_paint.png icon to represent jpeg’s. If you like it, just rename it to jpeg.png and you should be good to go.
This plugin is throwing errors with the latest build of EE - I had to disable gzip compression to get pages to show per this thread:
http://ellislab.com/forums/viewthread/129456/
Now it’s showing an error like this:
Warning: filesize() [function.filesize]: stat failed for /path/path/public_htmlhttp://domain.com/images/uploads/general/myfile.pdf in /path/path/public_html/system/plugins/pi.file_ext_icon.php on line 26
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.