Author Topic: How to add additional icon for file type?  (Read 2777 times)

fabiusp

  • Newbie
  • *
  • Posts: 10
    • View Profile
How to add additional icon for file type?
« on: April 30, 2009, 06:39:30 am »
Hello, I would like to have specific new icon for files uploaded.
I.e. an Autocad icon for any .dwg  file.

How can I do it?

ignacio

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
Re: How to add additional icon for file type?
« Reply #1 on: May 05, 2009, 07:12:38 pm »
Hi. Icons in OpenGoo are determined by the file's mime type, not the extension. Though I just made the changes so that in next release you can add an icon according to the extension. For the moment you have to deal with the mime type.

Assuming that the mime type is 'application/dwg' (you may have to google it or look in the og_project_file_revisions database table), you have to do this:

1) Add an image for the file type that is 16x16 pixels in size to 'public/assets/themes/default/images/16x16/types' and name it 'application-dwg.png' (the general rule for the filename is: replace slashes with dashes). The format doesn't need to be PNG, it could be GIF, but I don't know if ICO would work.

2) Add an image for the file type that is 48x48 pixels in size to 'public/assets/themes/default/images/48x48/types' and name it 'application-dwg.png'

3) In file 'public/assets/themes/default/stylesheets/custom.css' (if this file doesn't exist create it) add a couple of CSS rule for the file type, like this:
Code: [Select]
.ico-application-dwg {
background-image: url(../images/16x16/types/application-dwg.png);
}
.ico-large-application-dwg {
background-image: url(../images/48x48/types/application-dwg.png);
}

4) When file extension is supported you will be able to add the following rules:
Code: [Select]
.ico-ext-dwg {
background-image: url(../images/16x16/types/dwg.png);
}
.ico-large-ext-dwg {
background-image: url(../images/48x48/types/dwg.png);
}

5) Refresh your browser
« Last Edit: May 05, 2009, 07:14:15 pm by ignacio »

fabiusp

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: How to add additional icon for file type?
« Reply #2 on: May 08, 2009, 08:02:50 am »
Thank's for the input.
The mime type i've found on the og_project_file DB table for DWG files is: application/octet-stream

I created 16x16 icon 'application-octet-stream.png' on 'public/assets/themes/default/images/16x16/types'
and 48x48 icon 'application-octet-stream.png' on 'public/assets/themes/default/images/48x48/types'

Created 'public/assets/themes/default/stylesheets/custom.css'
containing:
Code: [Select]
.ico-application-octet-stream {
background-image: url(../images/16x16/types/application-octet-stream.png);
}
.ico-large-application-octet-stream {
background-image: url(../images/48x48/types/application-octet-stream.png);
}

Now I can see my icon on the file list, fine. But when I open the document's detail the "big" icon is not there.... any suggestions?


ignacio

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
Re: How to add additional icon for file type?
« Reply #3 on: May 18, 2009, 04:15:00 pm »
Hi, sorry for the delay.

application/octet-stream is a generic mime type for files with an unknown mime type, so the icon you set for this mimetype will be used by many types of files. It is better if you base the icon on the extension. Version 1.4 will be out either today so you will be able to use the file's extension to set the icon.

I don't know exactly why the large icon is not displayed, but there were some changes on how the large icon is chosen for this version, so it may be fixed. So my advise is: upgrade to the new version when it is available and set the icon for the dwg extension. (Remember to backup before upgrading!)

Regards.