mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-05-17 09:11:05 +00:00
parent
8c5a571293
commit
4ecfa5d35e
1 changed files with 13 additions and 8 deletions
|
|
@ -93,15 +93,20 @@ class ImageSpec(BaseImageSpec):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def cache_file_name(self):
|
def cache_file_name(self):
|
||||||
source_filename = self.source.name
|
source_filename = getattr(self.source, 'name', None)
|
||||||
ext = suggest_extension(source_filename, self.format)
|
|
||||||
return os.path.normpath(os.path.join(
|
|
||||||
settings.IMAGEKIT_CACHE_DIR,
|
|
||||||
os.path.splitext(source_filename)[0],
|
|
||||||
'%s%s' % (self.get_hash(), ext)))
|
|
||||||
|
|
||||||
return os.path.join(settings.IMAGEKIT_CACHE_DIR,
|
if source_filename is None or os.path.isabs(source_filename):
|
||||||
'%s%s' % (hash, ext))
|
# Generally, we put the file right in the cache directory.
|
||||||
|
dir = settings.IMAGEKIT_CACHE_DIR
|
||||||
|
else:
|
||||||
|
# For source files with relative names (like Django media files),
|
||||||
|
# use the source's name to create the new filename.
|
||||||
|
dir = os.path.join(settings.IMAGEKIT_CACHE_DIR,
|
||||||
|
os.path.splitext(source_filename)[0])
|
||||||
|
|
||||||
|
ext = suggest_extension(source_filename or '', self.format)
|
||||||
|
return os.path.normpath(os.path.join(dir,
|
||||||
|
'%s%s' % (self.get_hash(), ext)))
|
||||||
|
|
||||||
def __getstate__(self):
|
def __getstate__(self):
|
||||||
state = self.__dict__
|
state = self.__dict__
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue