summaryrefslogtreecommitdiff
path: root/ishtar_common/models.py
diff options
context:
space:
mode:
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
commit2af1621998bf20a0c46ab6c57cd6cd1e78681ad7 (patch)
tree2a9247e565cb97879958a660ffe098da1a6dc945 /ishtar_common/models.py
parent00e66866e7e6e9c8ee10739bad6e571bb879767f (diff)
downloadIshtar-2af1621998bf20a0c46ab6c57cd6cd1e78681ad7.tar.bz2
Ishtar-2af1621998bf20a0c46ab6c57cd6cd1e78681ad7.zip
Prevent to keep non resized images (refs #1365)
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r--ishtar_common/models.py4
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),