Fixes in imagefield
This commit is contained in:
parent
fbb2213e23
commit
d2a043c034
1 changed files with 15 additions and 2 deletions
|
|
@ -204,7 +204,7 @@ class ImageField(CharField):
|
||||||
if format_image!='JPEG' and format_image!='GIF' and format_image!='PNG':
|
if format_image!='JPEG' and format_image!='GIF' and format_image!='PNG':
|
||||||
|
|
||||||
self.error=True
|
self.error=True
|
||||||
self.txt_error='Format is wrong. Requires JPEG or PNG formats'
|
self.txt_error='Format is wrong. Requires GIF, JPEG or PNG formats'
|
||||||
im.close()
|
im.close()
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
@ -235,7 +235,7 @@ class ImageField(CharField):
|
||||||
|
|
||||||
save_file_thumb=self.save_folder+'/'+name+filename
|
save_file_thumb=self.save_folder+'/'+name+filename
|
||||||
|
|
||||||
im_thumb.thumbnail(size, Image.ANTIALIAS)
|
im_thumb.thumbnail(size, Image.LANCZOS)
|
||||||
im_thumb.save(save_file_thumb, "JPEG", quality=self.default_quality_thumb)
|
im_thumb.save(save_file_thumb, "JPEG", quality=self.default_quality_thumb)
|
||||||
|
|
||||||
im_thumb.close()
|
im_thumb.close()
|
||||||
|
|
@ -292,6 +292,19 @@ class ImageField(CharField):
|
||||||
if os.path.isfile(arr_image[self.name]):
|
if os.path.isfile(arr_image[self.name]):
|
||||||
|
|
||||||
os.remove(arr_image[self.name])
|
os.remove(arr_image[self.name])
|
||||||
|
|
||||||
|
if self.yes_thumbnail:
|
||||||
|
|
||||||
|
for tname, width_t in self.thumbnail.items():
|
||||||
|
|
||||||
|
old_dir_name=os.path.dirname(arr_image[self.name])
|
||||||
|
old_base_name=os.path.basename(arr_image[self.name])
|
||||||
|
|
||||||
|
old_thumb_name=old_dir_name+'/'+tname+old_base_name
|
||||||
|
|
||||||
|
if os.path.isfile(old_thumb_name):
|
||||||
|
os.remove(old_thumb_name)
|
||||||
|
|
||||||
|
|
||||||
self.model.yes_reset_conditions=old_reset
|
self.model.yes_reset_conditions=old_reset
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue