mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-05-05 11:54:43 +00:00
Storage can be specified on a per-spec basis.
If not defined on the spec, IKOptions.default_storage will be used. If that's not defined, it will fall back to the image field's storage.
This commit is contained in:
parent
57a28091c5
commit
8cfe485a5a
2 changed files with 10 additions and 2 deletions
|
|
@ -20,6 +20,12 @@ class Options(object):
|
|||
|
||||
"""
|
||||
|
||||
default_storage = None
|
||||
"""Storage used for specs that don't define their own storage explicitly.
|
||||
If neither is specified, the image field's storage will be used.
|
||||
|
||||
"""
|
||||
|
||||
crop_horz_field = 'crop_horz'
|
||||
crop_vert_field = 'crop_vert'
|
||||
preprocessor_spec = None
|
||||
|
|
@ -28,7 +34,6 @@ class Options(object):
|
|||
cache_filename_fields = ['pk', ]
|
||||
cache_filename_format = "%(filename)s_%(specname)s.%(extension)s"
|
||||
specs = None
|
||||
#storage = defaults to image_field.storage
|
||||
|
||||
def __init__(self, opts):
|
||||
for key, value in opts.__dict__.iteritems():
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ class ImageSpec(object):
|
|||
pre_cache = False
|
||||
quality = 70
|
||||
increment_count = False
|
||||
storage = None
|
||||
|
||||
def __init__(self, processors=None, **kwargs):
|
||||
if processors:
|
||||
|
|
@ -116,7 +117,9 @@ class Accessor(object):
|
|||
|
||||
@property
|
||||
def _storage(self):
|
||||
return getattr(self._obj._ik, 'storage', self._imgfield.storage)
|
||||
return getattr(self.spec, 'storage', None) or \
|
||||
getattr(self._obj._ik, 'default_storage', None) or \
|
||||
self._imgfield.storage
|
||||
|
||||
@property
|
||||
def url(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue