Search code examples
djangomedia-libraryfeincms

How should I extend the Django FeinCMS MediaLibrary?


We would like to extend the MediaLibrary of the Django FeinCMS without editing the module code itself.

We want

  • a few custom fields
  • and to use a library for individual cropping that we have already.

How should we put everything together?

The simplest approach would be to create an extensions model with a ForeignKey to the MediaLibrary, and to register a custom Admin site with an inline admin for the extensions model. But maybe there's a cleaner and better way.


Solution

  • As Hedde said, the media file model supports registering extensions the same way as the page module allows, using MediaFile.register_extensions.

    The method which is used for generating thumbnails in the media library should always be FEINCMS_MEDIALIBRARY_THUMBNAIL. The default value of this setting is feincms.module.medialibrary.thumbnail.default_admin_thumbnail which is a method that receives a media file object and returns the URL to a thumbnail or None.