django-files-widget by Maarten ter Horst, which greatly inspired this project.
Cropper by Chen Fengyuan.
This package can be views a Django package which tries to fully utilize jQuery File Upload, with minimal customization. Beside that, some of the ideas/code are inspired by Django-jfu and Django-files-widget.
Q: Why there isn’t a delete view for image in the widget?
A: Image upload behavior is much more complex than generic form views. Actually, the jQuery File Upload has a working delete button, but we changed it to an UI behavior of remove an instance from the gallery (no physical deletion), considered the following situations:
For the simplest case, when a user navigate away before saving the gallery they have just uploaded, it’s almost impossible to delete those images from client side.
Another situations happens when a gallery field is a required field. If there exists a delete view for the image instance, when a user tries to delete ALL the images he/she had previously saved, from the UI, and then he/she submit the form. Undoubtedly, the form will raise an invalid error, and the
GalleryFieldof the gallery instance won’t get updated. However, since all the image instances have been deleted before form submission, the form will then display broken images after reloading.
When an image presents in different galleries/albums, deletion of the image from one gallery will make it a broken image when view other galleries which contain it.
To avoid such situations, our suggestion is not to provide a delete view, but a strategy to identify
orphanedimage model instances, and delete them with a cron task: create an
M2Mrelationship between the image models and the gallery models. Through
post-savesignals of the gallery model, we are able to update the
M2Mrelationship between all image model instances and related gallery model instances. In this way, image model instances which were not involved in any
M2Mrelationship can be identified as
orphanedimages, the deletion of which are accurate and easy.
More detailed Documentation with more demos
Gif not client side croppable (don’t show crop button)
Scale large images in crop UI
Currently, it’s hard (although not impossible) to used the widget in a Non-model formfield.
Css rendering of buttons in Admin.
Gif will be converted to png (to retain gif, you need to set
Doesn’t support svg because django ImageField can’t handle it for now.
Released under the MIT license.