summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerman M. Bravo <german.mb@deipi.com>2013-10-06 11:04:42 -0500
committerGerman M. Bravo <german.mb@deipi.com>2013-10-06 11:05:00 -0500
commit0f2e4907ee6df6de5ee7b234a9a8d05b5a4aa1d9 (patch)
treef07d2e06673d157759ee8ceabc541a6e94e6a777
parent44d166cc2cbbcc31947ffe17a65d813c5a729a2a (diff)
downloadpyscss-0f2e4907ee6df6de5ee7b234a9a8d05b5a4aa1d9.tar.gz
Fixed incorrect use of undefined _path to get mime_type
-rw-r--r--scss/functions/compass/images.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/scss/functions/compass/images.py b/scss/functions/compass/images.py
index f76d0d3..3eab26c 100644
--- a/scss/functions/compass/images.py
+++ b/scss/functions/compass/images.py
@@ -50,7 +50,13 @@ def _image_url(path, only_path=False, cache_buster=True, dst_color=None, src_col
if not Image:
raise Exception("Images manipulation require PIL")
filepath = String.unquoted(path).value
- mime_type = inline and (String.unquoted(mime_type).value if mime_type else mimetypes.guess_type(filepath)[0])
+ fileext = os.path.splitext(filepath)[1].lstrip('.').lower()
+ if mime_type:
+ mime_type = String.unquoted(mime_type).value
+ if not mime_type:
+ mime_type = mimetypes.guess_type(filepath)[0]
+ if not mime_type:
+ mime_type = 'image/%s' % fileext
path = None
IMAGES_ROOT = _images_root()
if callable(IMAGES_ROOT):
@@ -108,7 +114,7 @@ def _image_url(path, only_path=False, cache_buster=True, dst_color=None, src_col
simply_process = False
image = None
- if _path.split('.')[-1] in ['cur']:
+ if fileext in ('cur',):
simply_process = True
else:
try:
@@ -118,8 +124,6 @@ def _image_url(path, only_path=False, cache_buster=True, dst_color=None, src_col
simply_process = True
if simply_process:
- if not mime_type:
- mime_type = 'image/%s' % _path.split('.')[-1]
if inline:
url = 'data:' + mime_type + ';base64,' + base64.b64encode(path.read())
else:
@@ -173,8 +177,6 @@ def _image_url(path, only_path=False, cache_buster=True, dst_color=None, src_col
new_image.save(output, format='PNG')
contents = output.getvalue()
output.close()
- if not mime_type:
- mime_type = 'image/%s' % _path.split('.')[-1]
url = 'data:' + mime_type + ';base64,' + base64.b64encode(contents)
else:
url = os.path.join(BASE_URL.rstrip('/'), filepath.lstrip('/'))