@@ -0,0 +1,1618 @@
+from django.contrib.admin.widgets import ForeignKeyRawIdWidget%0Afrom django.db import models%0Afrom django.utils.html import escape%0Afrom django.utils.text import truncate_words%0Afrom django.utils.translation import ugettext_lazy as _%0A%0Afrom feincms.admin.item_editor import FeinCMSInline%0Afrom feincms.module.medialibrary.models import MediaFile%0Afrom feincms.templatetags import feincms_thumbnail%0A%0A%0A__all__ = ('MediaFileForeignKey', 'ContentWithMediaFile')%0A%0A%0Aclass MediaFileForeignKeyRawIdWidget(ForeignKeyRawIdWidget):%0A    def label_for_value(self, value):%0A        key = self.rel.get_related_field().name%0A        try:%0A            obj = self.rel.to._default_manager.using(self.db).get(**%7Bkey: value%7D)%0A            label = %5Bu'&nbsp;%3Cstrong%3E%25s%3C/strong%3E' %25 escape(truncate_words(obj, 14))%5D%0A%0A            if obj.type == 'image':%0A                image = feincms_thumbnail.thumbnail(obj.file.name, '240x120')%0A                label.append(u'%3Cbr /%3E%3Cimg src=%22%25s%22 alt=%22%22 style=%22margin:1em 0 0 10em%22 /%3E' %25 image)%0A%0A            return u''.join(label)%0A        except (ValueError, self.rel.to.DoesNotExist):%0A            return ''%0A%0A%0Aclass MediaFileForeignKey(models.ForeignKey):%0A    def formfield(self, **kwargs):%0A        kwargs%5B'widget'%5D = MediaFileForeignKeyRawIdWidget(self.rel, kwargs.get('using'))%0A        return super(MediaFileForeignKey, self).formfield(**kwargs)%0A%0A%0Aclass ContentWithMediaFile(models.Model):%0A    class feincms_item_editor_inline(FeinCMSInline):%0A        raw_id_fields = ('file',)%0A%0A    file = MediaFileForeignKey(MediaFile, verbose_name=_('media file'),%0A        related_name='+')%0A%0A    class Meta:%0A        abstract = True%0A

Add a MediaFileForeignKey which automatically adds thumbnail previews to the administration