Mimetypes Management
Introduction
ownCloud allows you to create aliases for mimetypes and map file extensions to a mimetype. These allow administrators the ability to change the existing icons that ownCloud uses to represent certain file types and folders, as well as to use custom icons for mimetypes and file extensions which ownCloud doesn’t natively support.
This is handy in a variety of situations, e.g. if you want a custom audio icon for audio mimetypes instead of the default file icon.
By default, the folder containing the relevant configuration is not part of the Docker volume. To access it, you must first create additional Docker volumes pointing the the correct container paths. When using the example mount points, it is necessary to adapt them accordingly:
/var/www/owncloud/resources --> <mount-point-resources>
/var/www/owncloud/core/img/filetypes --> <mount-point-filetypes>
The folder for the ownCloud config is already a mounted Docker volume and accessible under <mount-point>/config.
Mimetype Aliases
ownCloud’s default mimetype configuration is defined in
<mount-point-resources>/config/mimetypealiases.dist.json
Below you can see a snippet of the file where the mimetype’s on the left and the icon used to represent that mimetype is on the right.
{
"application/coreldraw": "image",
"application/font-sfnt": "image",
"application/font-woff": "image",
"application/illustrator": "image",
"application/epub+zip": "text",
"application/javascript": "text/code"
}
You can see that:
-
the image icon is used to represent Corel Draw, SFNT and WOFF font files, and Adobe Illustrator files,
-
ePub files are represented by the text file icon,
-
JavaScript files are represented by the text/code icon.
Changing Existing Icons and Using Custom Icons
If you want to change one or more of the existing icons which ownCloud uses, or if you want to expand the available list, here’s how to do so:
First, create a copy of
<mount-point-resources>/config/mimetypealiases.dist.json
and save it as
<mount-point>/config/mimetypealiases.json
This is required for two reasons:
-
It will take precedence over the default file.
-
The original file will get replaced on each ownCloud upgrade.
Then, either override one or more existing definitions or add new custom aliases as required.
| Please refer to the ownCloud theming documentation for where to put the new image files. |
Some common mimetypes that may be useful in creating aliases are:
| Mimetype | Description |
|---|---|
|
Generic image |
|
Vector image |
|
Generic audio file |
|
Word processed document |
|
Spreadsheet |
|
Presentation |
|
Generic text document |
|
Source code |
Once you have made changes to
<mount-point>/config/mimetypealiases.json
use the occ command to propagate the changes throughout your ownCloud installation:
docker compose exec owncloud occ maintenance:mimetype:update-js
Example - Changing the JSON File Icon
The following example will show you how to change the icon that ownCloud uses to represent JSON files.

-
Copy the following file
<mount-point-resources>/config/mimetypealiases.dist.jsonto
<mount-point>/config/mimetypealiases.json -
Update the alias for
application/json, which you should find on line 8, to match the following, and save the file:"application/json": "text/json", -
Copy a new SVG icon to represent JSON files to
<mount-point-filetypes>, calling ittext-json.svg.The name and location of the file are important.
-
The location is, because the
<mount-point-filetypes>directory stores the mimetype file icons. -
The name is important, as it’s a rough mapping between the alias name and the icon’s file name, i.e.,
text/jsonbecomestext-json.
-
-
Run the following command to update the mimetype alias database.
docker compose exec owncloud occ maintenance:mimetype:update-js
After doing so, whenever you view a folder that contains JSON files or upload one, your new icon file will be used to represent the file, as in the image below.

Mimetype Mapping
ownCloud allows administrators to map a file extension to a mimetype, e.g., such as mapping files ending in mp3 to audio/mpeg. Which then, in turn, allows ownCloud to show the audio icon.
The default file extension to mimetype mapping configuration is stored in
<mount-point-resources>/config/mimetypemapping.dist.json
This is similar to
<mount-point-resources>/config/mimetypealiases.dist.json
and also returns a basic JSON array.
{
"3gp": ["video/3gpp"],
"7z": ["application/x-7z-compressed"],
"accdb": ["application/msaccess"],
"ai": ["application/illustrator"],
"apk": ["application/vnd.android.package-archive"],
"arw": ["image/x-dcraw"],
"avi": ["video/x-msvideo"],
"bash": ["text/x-shellscript"],
"json": ["application/json", "text/plain"]
}
In the example above, you can see nine mimetypes mapped to file extensions. Each of them, except the last (json), maps a file extension to a mimetype. Now take a look at the JSON example.
In this case, ownCloud will first check if a mimetype alias is defined for application/json, in mimetypealiases.json. If it is, it will use that icon. If not, then ownCloud will fall back to using the icon for text/plain.
If you want to update or extend the existing mapping, as with updating the mimetype aliases, create a copy of
<mount-point-resources>/config/mimetypemapping.dist.json
and save it as
<mount-point>config/mimetypemapping.json
Then, in this new file, make any changes required.
| Please refer to the ownCloud theming documentation for where to put the new image files. |
Icon Retrieval
When an icon is retrieved for a mimetype, if the full mimetype cannot be found, the search will fallback to looking for the part before the slash. Given a file with the mimetype image/my-custom-image, if no icon exists for the full mimetype, the icon for image will be used instead. This allows specialized mimetypes to fallback to generic icons when the relevant icons are unavailable.