mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-03-16 21:30:23 +00:00
Processors no longer callable
This commit is contained in:
parent
dc84144d6b
commit
461fbaef1a
2 changed files with 3 additions and 16 deletions
|
|
@ -20,14 +20,7 @@ class ImageSpecField(SpecHost):
|
|||
image_cache_backend=None, image_cache_strategy=None, spec=None,
|
||||
id=None):
|
||||
|
||||
# The spec accepts a callable value for processors, but it
|
||||
# takes different arguments than the callable that ImageSpecField
|
||||
# expects, so we create a partial application and pass that instead.
|
||||
# TODO: Should we change the signatures to match? Even if `instance` is not part of the signature, it's accessible through the source file object's instance property.
|
||||
p = lambda file: processors(instance=file.instance,
|
||||
file=file) if callable(processors) else processors
|
||||
|
||||
SpecHost.__init__(self, processors=p, format=format,
|
||||
SpecHost.__init__(self, processors=processors, format=format,
|
||||
options=options, storage=storage, autoconvert=autoconvert,
|
||||
image_cache_backend=image_cache_backend,
|
||||
image_cache_strategy=image_cache_strategy, spec=spec,
|
||||
|
|
|
|||
|
|
@ -92,16 +92,10 @@ class BaseImageSpec(object):
|
|||
self.options = options or self.options
|
||||
self.autoconvert = self.autoconvert if autoconvert is None else autoconvert
|
||||
|
||||
def get_processors(self, source_file):
|
||||
processors = self.processors
|
||||
if callable(processors):
|
||||
processors = processors(source_file)
|
||||
return processors
|
||||
|
||||
def get_hash(self, source_file):
|
||||
return md5(''.join([
|
||||
source_file.name,
|
||||
pickle.dumps(self.get_processors(source_file)),
|
||||
pickle.dumps(self.processors),
|
||||
self.format,
|
||||
pickle.dumps(self.options),
|
||||
str(self.autoconvert),
|
||||
|
|
@ -125,7 +119,7 @@ class BaseImageSpec(object):
|
|||
original_format = img.format
|
||||
|
||||
# Run the processors
|
||||
processors = self.get_processors(source_file)
|
||||
processors = self.processors
|
||||
img = ProcessorPipeline(processors or []).process(img)
|
||||
|
||||
options = dict(self.options or {})
|
||||
|
|
|
|||
Loading…
Reference in a new issue