Skip to content

Commit

Permalink
remove thumbnail auto-removal
Browse files Browse the repository at this point in the history
  • Loading branch information
dulmandakh committed Nov 3, 2024
1 parent a2c7e57 commit 3f31fd9
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 20 deletions.
1 change: 0 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Features at a glance
- Admin integration with possibility to delete
- Dummy generation (placeholders)
- Flexible, simple syntax, generates no html
- ImageField for model that deletes thumbnails (only compatible with django 1.2.5 or less)
- CSS style cropping options
- Back smart cropping, and remove borders from the images when cropping
- Margin calculation for vertical positioning
Expand Down
19 changes: 0 additions & 19 deletions sorl/thumbnail/fields.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django import forms
from django.db import models
from django.db.models import Q
from django.utils.translation import gettext_lazy as _

from sorl.thumbnail import default
Expand All @@ -9,24 +8,6 @@


class ImageField(models.ImageField):
def delete_file(self, instance, sender, **kwargs):
"""
Adds deletion of thumbnails and key value store references to the
parent class implementation. Only called in Django < 1.2.5
"""
file_ = getattr(instance, self.attname)

# If no other object of this type references the file, and it's not the
# default value for future objects, delete it from the backend.
query = Q(**{self.name: file_.name}) & ~Q(pk=instance.pk)
qs = sender._default_manager.filter(query)

if (file_ and file_.name != self.default and not qs):
default.backend.delete(file_)
elif file_:
# Otherwise, just close the file, so it doesn't tie up resources.
file_.close()

def formfield(self, **kwargs):
defaults = {'form_class': ImageFormField}
defaults.update(kwargs)
Expand Down

0 comments on commit 3f31fd9

Please sign in to comment.