From 2af1621998bf20a0c46ab6c57cd6cd1e78681ad7 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 4 Sep 2013 17:37:58 +0200 Subject: Prevent to keep non resized images (refs #1365) --- ishtar_common/models.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'ishtar_common/models.py') diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 893c3b481..fb6bebed7 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -294,6 +294,7 @@ class ImageModel(models.Model): if self.has_changed('image'): # convert to jpg filename = os.path.splitext(os.path.split(self.image.name)[-1])[0] + old_path = self.image.path filename = "%s.jpg" % filename image = Image.open(self.image.file) @@ -306,6 +307,9 @@ class ImageModel(models.Model): self.create_thumb(image, self.IMAGE_MAX_SIZE), save=False) + if old_path != self.image.path: + os.remove(old_path) + # save the thumbnail self.thumbnail.save('_%s' % filename, self.create_thumb(image, self.THUMB_MAX_SIZE), -- cgit v1.2.3