diff options
author | Étienne Loks <etienne.loks@peacefrogs.net> | 2013-09-04 17:37:58 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2013-09-04 17:37:58 +0200 |
commit | 2af1621998bf20a0c46ab6c57cd6cd1e78681ad7 (patch) | |
tree | 2a9247e565cb97879958a660ffe098da1a6dc945 | |
parent | 00e66866e7e6e9c8ee10739bad6e571bb879767f (diff) | |
download | Ishtar-2af1621998bf20a0c46ab6c57cd6cd1e78681ad7.tar.bz2 Ishtar-2af1621998bf20a0c46ab6c57cd6cd1e78681ad7.zip |
Prevent to keep non resized images (refs #1365)
-rw-r--r-- | ishtar_common/models.py | 4 |
1 files changed, 4 insertions, 0 deletions
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), |