How to add Icons for new Mime Types?

How to add Icons for new Mime Types?

by Res Hotz-Pohlmann -
Number of replies: 8
I succeeded in changing existing file icons (as word.gif, image.gif...). But how do I add an icon for a new mime type (eg. MS Access, ...)?
Average of ratings: -
In reply to Res Hotz-Pohlmann

Re: How to add Icons for new Mime Types?

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi Res,

AFAIK you would need to amend lib/filelib.php and add an icon gif to pix/f.
Average of ratings: Useful (1)
In reply to Helen Foster

Re: How to add Icons for new Mime Types?

by Res Hotz-Pohlmann -

Hi Helen

That's exactly what I tried.

Code snipet from lib/filelib.php (red line = new line):
...
    'm'    => array ('type'=>'text/plain', 'icon'=>'text.gif'),
    'mdb'  => array ('type'=>'application/vnd.ms-access', 'icon'=>'access.gif'),
    'mov'  => array ('type'=>'video/quicktime', 'icon'=>'video.gif'),
...

and naturally I added the icon "access.gif" to pix/f.

But it doesn't work! Even if I change any 'icon'=> - statement in lib/filelib.php it doesn't cause any effect on the file icons shown in my courses. eg:

...
        'doc'  => array ('type'=>'application/msword', 'icon'=>'text.gif'),
...

and my word documents keep showing their nice word icon. What could be wrong?

Average of ratings: Useful (1)
In reply to Res Hotz-Pohlmann

Re: How to add Icons for new Mime Types?

by Res Hotz-Pohlmann -

Ok, I found the answer by myself:

As long as I didn't make any changes to my course, my course resources kept showing the old icons. As soon as I added another resource to my course, all icons were renewed!

There must be any cache, maybe on my PC, maybe on the server, which caches these icons and is just swapped when any change to the resources is made. I'm glad to have got my new icons anyway, but I really would be interessted in the location of this cache. Because I tried to empty any cache on my PC by deleting all temporary internet files before...

In reply to Res Hotz-Pohlmann

Re: How to add Icons for new Mime Types?

by Sergio Di Fiore -

Actually, this cache seens to work for everithing... I myself had problems from my personal picture to figures like jpeg or gif that I add to my lessons.

You just can't change then, unless you use another name...

Knowing how to clean this cache would'be very nice, and most of all, usefull...

Apreciate anyone who can tell us how to do that!

In reply to Res Hotz-Pohlmann

Re: How to add Icons for new Mime Types?

by Mark Granger -

What is the best way to add mime type icons that would be upgrade safe. Is there anyway the graphics and mime type code can be self contained within a theme.

The graphics can go into pix/f and use custom pix. But what about the lib/filelib.php changes?

Thanks for any help.

In reply to Res Hotz-Pohlmann

re: How to add Icons for new Mime Types?

by sho yong -
maybe a restart of the web server (apache or IIS)??