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 | 09c981742088b17d54cff81237d91fb66da1db81 (patch) | |
tree | 2a9247e565cb97879958a660ffe098da1a6dc945 /ishtar_common/models.py | |
parent | a17e992687d7e06ff4e2f04d28f5a3ababedfeff (diff) | |
download | Ishtar-09c981742088b17d54cff81237d91fb66da1db81.tar.bz2 Ishtar-09c981742088b17d54cff81237d91fb66da1db81.zip |
Prevent to keep non resized images (refs #1365)
Diffstat (limited to 'ishtar_common/models.py')
-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), |