Return to Snippet

Revision: 22547
at January 15, 2010 04:43 by renaars


Initial Code
function extensionToIcon($filename)
{
	$filename = strtolower($filename);
	$ext = strtolower(substr($filename,strrpos($filename,".")));
	$icnext = "png";
	if(strrpos($_SERVER['HTTP_USER_AGENT'],"MSIE 6.0"))
	{
	    $icnext = "gif";
	}
	if($ext == ".pdf")
	{
		return "document_text_image.$icnext";
	}
	else if(in_array($ext,array( ".mov" , ".flv" , ".avi" , ".mpeg" , ".mpg" , ".wmv", ".mp4",)))
	{
		return "film.$icnext";
	}
	else if(in_array($ext,array( ".mp3" , ".aac" , ".wav" , ".wma" ,)))
	{
		return "music_beam_16.$icnext";
	}
	else if(in_array($ext,array( ".jpg" , ".jpeg" , ".png" , ".gif" , ".bmp" ,)))
	{
		return "image.$icnext";
	}
	else if(in_array($ext,array( ".txt" , ".rtf" ,)))
	{
		return "document_text.$icnext";
	}
	else if(in_array($ext,array( ".doc" , ".docx" ,)))
	{
		return "document_word_text.$icnext";
	}
	else if(in_array($ext,array( ".xls" ,)))
	{
		return "document_excel_table.$icnext";
	}
	else if(in_array($ext,array( ".sql" , ".mdb")))
	{
		return "database.$icnext";
	}
	else if(in_array($ext,array( ".zip" , ".7z" , ".rar" , ".gz" , ".tar")))
	{
		return "document_zipper.$icnext";
	}
	else if($ext == $filename)
	{
		return "folder_horizontal_open.$icnext";
	}
	else
	{
		return "document.$icnext";
	}
}

Initial URL

                                

Initial Description
works with fugue icons, but can be custumized

Initial Title
filename to icon

Initial Tags
files

Initial Language
PHP