Add New Mimetype in 2.6

Add New Mimetype in 2.6

by Jeff Ferrell -
Number of replies: 1

I'm trying to add a mimetype for mobi files, so I can display a proper icon in my courses, but I can't get the new icon to display.

I've added a couple of lines to filelib.php:

'mobi' => array ('type'=>'application/x-mobipocket-ebook', 'icon'=>'mobi'),
'mobi' => array ('type'=>'AZW/Mobi', 'icon'=>'mobi'),

(For the record, I added the second after the first didn't work, just to see...)

I've added the appropriate icons to my theme's pix_core/f/ folder, where there are other icons currently overriding the defaults. I also used "Purge all caches" from the Administration > Development menu, to see if that would help. Just for kicks, I added the mimetype to my server's .htaccess: AddType application/x-mobipocket-ebook .mobi

Nothing seems to work.

The problem seems to be that Moodle isn't recognizing the mimetype. In the HTML, the icon reads as:

component=core&image=f%2Funknown-24

Can anyone spot what I'm doing wrong? Still the wrong mimetype name, maybe?

Average of ratings: -
In reply to Jeff Ferrell

Re: Add New Mimetype in 2.6

by Jeff Ferrell -

I think I've got it—here's what I learned, for future reference:

(1) I probably should have tried this earlier, but clicking the "display file details" button in the uploader show the mimetype of the files you're uploading. In this case, it turns out I needed AZW/mobi. Huh.

(2) Out of desperation, I threw my same mobi.png files into the core pix/f/ folder, and the mobi icons all of a sudden appeared as expected. That didn't make sense, since my epub icons in my theme's pix_core/f/ folder were overriding the original epub icons. And then it did make sense—I'm guessing that my mobi icons in my theme's folder weren't overriding Moodle's default icon because there was no default icon to override in the first place. When I added a mobi icon to the core, everything clicked into place.

Main lesson? When adding a completely new mimetype, add the icons to the core instead of the theme. (I suppose.)