mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-03-17 05:40:25 +00:00
format_to_extension correctly handles None arg
This commit is contained in:
parent
3022eb037d
commit
dd642fd05b
1 changed files with 10 additions and 7 deletions
|
|
@ -97,9 +97,10 @@ def _extension_to_format(extension):
|
|||
|
||||
|
||||
def _format_to_extension(format):
|
||||
for k, v in Image.EXTENSION.iteritems():
|
||||
if v == format.upper():
|
||||
return k
|
||||
if format:
|
||||
for k, v in Image.EXTENSION.iteritems():
|
||||
if v == format.upper():
|
||||
return k
|
||||
return None
|
||||
|
||||
|
||||
|
|
@ -121,11 +122,13 @@ def format_to_extension(format):
|
|||
"""Returns the first extension that matches the provided format.
|
||||
|
||||
"""
|
||||
extension = _format_to_extension(format)
|
||||
if not extension and _preinit_pil():
|
||||
extension = _format_to_extension(format)
|
||||
if not extension and _init_pil():
|
||||
extension = None
|
||||
if format:
|
||||
extension = _format_to_extension(format)
|
||||
if not extension and _preinit_pil():
|
||||
extension = _format_to_extension(format)
|
||||
if not extension and _init_pil():
|
||||
extension = _format_to_extension(format)
|
||||
if not extension:
|
||||
raise UnknownFormatError(format)
|
||||
return extension
|
||||
|
|
|
|||
Loading…
Reference in a new issue