The MimeType is a little thumbnail displayed next to the title that is usually related to the type of information contained in the article, or a logo for the page that we're addressing. If you make a search in google for example you can appreciate the Mime icon right here
In our case, we use this feature, for example, to differentiate between types of documents that we're displaying on data warehouses by using icons instead of displaying the whole category of the document in screen.
MimeField
Property | Type | Default | Description |
---|---|---|---|
map_file | str | - | Path to the file that contains the mapping for this dynamic field. |
alt | Optional[str] | 'default' | Alt option for display in case the specified mimetype does not exist in the map. |
_MimeFieldUI Class
Property | Type | Default | Description |
---|---|---|---|
type | Literal[DynamicFieldType.MIME_TYPE] | DynamicFieldType.MIME_TYPE | Type of the field (Literal with value DynamicFieldType.MIME_TYPE). |
Mapping
Since we have separated the front end from the backend, we made this field work with a map that maps the content of a field in the database (example Category) with it's corresponding Mime icon path in the UI. Our recommendation is to place the map at config/stages/fields/mimetype/ but you can give any path to the map_file property in the configuration.
The Map must be in json format so it can be read as a Python dictionary, here's an example of what a map should look like:
{ "Documentary": "src/assets/Icons/documento.svg", "default": "src/assets/Icons/filas-de-la-tabla.svg" }
Example Configuration
thumbnail=MimeField(field='metadata.genres[0].name', map_file='config/stages/fields/mimetype/mime_maps.json')