Opened 9 years ago

Closed 6 years ago

Last modified 2 years ago

#5476 closed Uncategorized (wontfix)

Image thumbnails on image fields in the admin

Reported by: rich@… Owned by: xian
Component: contrib.admin Version: master
Severity: Normal Keywords: nfa-someday admin, thumbnails imagefields
Cc: jdunck+django@… Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I think it would be pretty nifty if the newforms-admin could render image thumbnails on image upload fields. It's a snippet but why do more when forms are already getting jazzed up and it goes a long way in usability?

Attachments (3)

image-preview-in-admin.patch (2.6 KB) - added by vitja 8 years ago.
preview image on model admin page
image-preview-in-admin.diff (2.6 KB) - added by vitja 8 years ago.
preview image on model admin page (2.5 KB) - added by vitja 8 years ago.
thumbnail field

Download all attachments as: .zip

Change History (17)

comment:1 Changed 9 years ago by webjunkie

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Design decision needed

comment:2 follow-up: Changed 9 years ago by deepak <deep.thukral@…>

For the sake of simplicity -1 from me. Django shouldn't require any external package forcibly.

comment:3 in reply to: ↑ 2 Changed 9 years ago by ubernostrum

Replying to deepak <>:

For the sake of simplicity -1 from me. Django shouldn't require any external package forcibly.

Django's ImageField already requires PIL, so this wouldn't change anything. Similarly, XMLField requires Jing, memcached caching requires the memcached bindings and using a database (except SQLite when using Python 2.5) requires a database adapter module.

comment:4 Changed 9 years ago by ubernostrum

See also #4115 and #961.

comment:5 Changed 9 years ago by xian

  • Keywords admin thumbnails imagefields added
  • Owner changed from nobody to xian
  • Version changed from SVN to newforms-admin

Assigning this to myself and moving to newforms-admin. As I'm doing newforms-admin interface work. :)

I'd like to see thumbnails for imagefields in both the change_list and the form itself if there is already an image set. However this only makes sense to do if #4115 happens. And if it does it should happen in templates/templatetags for the admin not in the model as in the linked-to snippet.

comment:6 Changed 9 years ago by anonymous

  • Cc jdunck+django@… added

comment:7 Changed 9 years ago by brosner

  • Keywords nfa-someday added

This functionality is not critical before the merge to trunk. Tagging with nfa-someday.

Changed 8 years ago by vitja

preview image on model admin page

comment:8 Changed 8 years ago by vitja


I've recently attached patch, that shows image on admin page:

image = models.ImageField(admin_preview=True)

I'm going to create generic way of creating thumbnails, so could you give me a tip.
I think that should be field, e.g.

image_thumb = ImageThumbField(thumb_for='image', thumbnalizer=create_100x100_thumb)

so adding thumbs to list_view will be as easy as:

def get_thumb(self):
    return '<img src="%s" />' % self.get_thumb_url

or even:

def get_thumb():

Changed 8 years ago by vitja

preview image on model admin page

Changed 8 years ago by vitja

thumbnail field

comment:9 Changed 8 years ago by Alex

  • Version changed from newforms-admin to SVN

comment:10 Changed 8 years ago by floledermann

This snippet is a much better starting point:

I just looked around in the source files and I think it cannot be done with template work alone, but one has to create an ImageWidget for the admin like in the snippet. I got this code working on my site in a few minutes and I think this would be a good basis for a patch. It only depends on PIL but degrades gracefully if not present.

Is there anything I can do to help (I have not yet contributed to Django code, so would need some guidance)

comment:11 Changed 6 years ago by mtredinnick

  • Resolution set to wontfix
  • Status changed from new to closed

There seem to be too many variable preferences required here for how the thumbnail display would work. It's a lot of complexity to put it into the admin by default. Fortunately, it's possible without modifying Django for individual apps: specify a model form on the ModelAdmin subclass and a widget for that field that is the custom widget that display the thumbnail.

comment:12 Changed 4 years ago by anonymous

  • Easy pickings unset
  • Severity set to Normal
  • Type set to Uncategorized
  • UI/UX unset

comment:13 Changed 2 years ago by anonymous

@mtredinnick It's easy to say "it's easy"; it's harder (though not all that much) to actually provide documentation and example code so that a non-Django-expert can understand how to add thumbnails to their admin.

In other words, you can quibble over whether or not thumbnail support should be built in to Django, but you can't argue with the fact that right now it's more difficult than it needs to be for someone to have thumbnails in their admin. If it's not going to be built in, it would benefit Django to have some explanation of the non-built-in way of doing thumbnails.

comment:14 Changed 2 years ago by russellm

Firstly - It's worth pointing out that @mtredinnick is deceased.

Secondly, you've apparently missed the point of what he was saying -- there isn't a single, obvious way to do this. It would be impossible for Django to document how it could be done without "blessing" a particular approach. This would almost certainly involve blessing one of the third-party thumbnailing libraries, (sorl-thumbnails and easy-thumbnails to pick just two).

More broadly, as a project, we have an open problem of helping newcomers find appropriate third-party tools in the Django ecosystem. However, I don't think we can address that problem by documenting examples that use selected packages.

Note: See TracTickets for help on using tickets.
Back to Top