Closed vchrisb closed 2 years ago
I looked at the code an there is not yet a post_delete
signal attached.
@codingjoe do you want to have a delete orphaned functionality as part of this library or do you consider to document the usage of https://github.com/un1t/django-cleanup?
To be able to use django-cleanup, I only had to modify https://github.com/codingjoe/django-pictures/blob/main/pictures/models.py#L105 to check if also the instance has the width_field
attribute. Django-cleanup is using a "FakeInstance".
e.g.
@property
def width(self):
self._require_file()
if self._committed and self.field.width_field and hasattr(self.instance, self.field.width_field):
# get width from width field, to avoid loading image
return getattr(self.instance, self.field.width_field)
return self._get_image_dimensions()[0]
Directories are not deleted currently.
@vchrisb this is the last feature on my list. However, cleanup
seems mature and a better choice than a custom implementation. What do you think? Oh, and I'd be delighted if you find a second to implement this bit. :)
django-stdimage
has an option to delete orphaned images (delete_orphans=True
), when updating an image or deleting the associated image. It would be great ifdjango-pictures
would have a similar capability.Additionality when removing an
aspect_ratio
from a model, the obsolete images are not deleted.