Skip to content

Commit f60bb06

Browse files
authored
remove thumbnail auto-removal (#777)
1 parent 5e170fb commit f60bb06

File tree

2 files changed

+0
-20
lines changed

2 files changed

+0
-20
lines changed

README.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Features at a glance
1313
- Admin integration with possibility to delete
1414
- Dummy generation (placeholders)
1515
- Flexible, simple syntax, generates no html
16-
- ImageField for model that deletes thumbnails (only compatible with django 1.2.5 or less)
1716
- CSS style cropping options
1817
- Back smart cropping, and remove borders from the images when cropping
1918
- Margin calculation for vertical positioning

sorl/thumbnail/fields.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from django import forms
22
from django.db import models
3-
from django.db.models import Q
43
from django.utils.translation import gettext_lazy as _
54

65
from sorl.thumbnail import default
@@ -9,24 +8,6 @@
98

109

1110
class ImageField(models.ImageField):
12-
def delete_file(self, instance, sender, **kwargs):
13-
"""
14-
Adds deletion of thumbnails and key value store references to the
15-
parent class implementation. Only called in Django < 1.2.5
16-
"""
17-
file_ = getattr(instance, self.attname)
18-
19-
# If no other object of this type references the file, and it's not the
20-
# default value for future objects, delete it from the backend.
21-
query = Q(**{self.name: file_.name}) & ~Q(pk=instance.pk)
22-
qs = sender._default_manager.filter(query)
23-
24-
if (file_ and file_.name != self.default and not qs):
25-
default.backend.delete(file_)
26-
elif file_:
27-
# Otherwise, just close the file, so it doesn't tie up resources.
28-
file_.close()
29-
3011
def formfield(self, **kwargs):
3112
defaults = {'form_class': ImageFormField}
3213
defaults.update(kwargs)

0 commit comments

Comments
 (0)