Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I wanted to post this for those that may need it and were having problems with getting the MIME types to work on some file types.
I have a project that required .dwf, .dwg, .sldprt, .sldasm, .slddrw file types. I added this to the function file_document_mime_types() (starts on line #59 in alpha3, alpha4 and dev versions):
'application/dwg' => array(
'name' => t('AutoCAD Drawing'),
'icon' => 'dwg.gif',
),
'application/dwf' => array(
'name' => t('Autodesk Drawing Web Format'),
'icon' => 'dwf.gif',
),
'application/sldworks' => array(
'name' => t('Solidworks Assembly File'),
'icon' => 'sldasm.gif',
),
'application/sldworks' => array(
'name' => t('SolidWorks Part File'),
'icon' => 'sldprt.gif',
),
'application/sldworks' => array(
'name' => t('Solidworks Drawing File'),
'icon' => 'slddrw.gif',
),
I've also attached the icons I found and modified (for transparent backgrounds) for these file types.
I hope that helps someone else.
Comment | File | Size | Author |
---|---|---|---|
sldprt.gif | 596 bytes | visualnotion | |
slddrw.gif | 338 bytes | visualnotion | |
sldasm.gif | 612 bytes | visualnotion | |
dwg.gif | 625 bytes | visualnotion | |
dwf.gif | 1.04 KB | visualnotion |
Comments
Comment #1
visualnotion CreditAttribution: visualnotion commentedI should have included this info in the above topic, as well.
I used these sites for finding the MIME types and icons (if it keeps someone else from having to waste time digging for it elsewhere):
Comment #2
miglius CreditAttribution: miglius commentedThanks for sharing it. I'm curious - I understand that this code will print the icon and the MIME description in the MIME listing page, but I don't see how it can really help in detecting the MIME type from the file extension. So I assume that MIME detection for you was working even before those lines were added? Wasn't it the case?
The code above is intended to extend the mime.types mapping, but to do that you would need to add an 'extensions' key which would associate the MIME type with file extension:
Comment #3
ctalley5 CreditAttribution: ctalley5 commentedWow I'm so glad you posted this... exactly what I was going to ask about (DWG & DWF formats). So when you upload a DWG file using this format, does it automatically create a preview of it & PDF view?
Thanks for posting this, really helpful.
Comment #4
ctalley5 CreditAttribution: ctalley5 commentedHowever - I'm new... and am sure i am overlooking something, or looking at the wrong files.
Searching for function file_document_mime_types() (starts on line #59 .... I am unable to find. Has this code been changed since?
Comment #5
miglius CreditAttribution: miglius commentedDWG or DWF files are not automatically converted to PDF unless there is any conversion utility which could be used by this module.
Comment #6
ctalley5 CreditAttribution: ctalley5 commentedAhh I see... That's fine.
I'm still curious though, why I cannot seem to find the function "file_document_mime_types" anywhere.
Thanks,
Comment #7
miglius CreditAttribution: miglius commentedIt is in the 'fileframework/formats/document/file_document.module file.
Comment #8
ctalley5 CreditAttribution: ctalley5 commentedOkay have it all figured out..... have a DWG upload, as well as Icon working. Thanks for your help.
Now - I understand that .DWG filetypes have the capability of providing previews. I was curious if it was going to show up - but i guess nothing's that easy, right.
Does anybody have any ideas about that?
Thanks again - module's great.
Comment #9
johanneshahn CreditAttribution: johanneshahn commentedno activity