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

Description

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? http://www.djangosnippets.org/snippets/239/

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
thumbnail-field-and-example.py (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 Julian Bez

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Triage Stage: UnreviewedDesign decision needed

comment:2 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 James Bennett

Replying to deepak <deep.thukral@gmail.com>:

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 James Bennett

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: SVNnewforms-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 Brian Rosner

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

Hi!

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
get_thumbs.allow_tags=True

or even:

@image_tag_for('thumb')
def get_thumb():
    pass

Changed 8 years ago by vitja

Attachment: image-preview-in-admin.diff added

preview image on model admin page

Changed 8 years ago by vitja

thumbnail field

comment:9 Changed 8 years ago by Alex Gaynor

Version: newforms-adminSVN

comment:10 Changed 8 years ago by Flo Ledermann

This snippet is a much better starting point:

http://www.djangosnippets.org/snippets/934/

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 Malcolm Tredinnick

Resolution: wontfix
Status: newclosed

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: Normal
Type: 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 Russell Keith-Magee

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