diff --git a/autoload/emmet/lang/haml.vim b/autoload/emmet/lang/haml.vim index 98fbec5..d1ee396 100644 --- a/autoload/emmet/lang/haml.vim +++ b/autoload/emmet/lang/haml.vim @@ -120,7 +120,10 @@ function! emmet#lang#haml#imageSize() if fn =~ '^\s*$' return elseif fn !~ '^\(/\|http\)' - let fn = simplify(expand('%:h') . '/' . fn) + let fn = resolve(expand(fn)) + if !filereadable(fn) + let fn = simplify(expand('%:h') . '/' . fn) + endif endif let [width, height] = emmet#util#getImageSize(fn) diff --git a/autoload/emmet/lang/html.vim b/autoload/emmet/lang/html.vim index 382767a..e9a4a8f 100644 --- a/autoload/emmet/lang/html.vim +++ b/autoload/emmet/lang/html.vim @@ -444,7 +444,10 @@ function! emmet#lang#html#imageSize() if fn =~ '^\s*$' return elseif fn !~ '^\(/\|http\)' - let fn = simplify(expand('%:h') . '/' . fn) + let fn = resolve(expand(fn)) + if !filereadable(fn) + let fn = simplify(expand('%:h') . '/' . fn) + endif endif let [width, height] = emmet#util#getImageSize(fn) diff --git a/autoload/emmet/lang/slim.vim b/autoload/emmet/lang/slim.vim index 267f7f4..8367435 100644 --- a/autoload/emmet/lang/slim.vim +++ b/autoload/emmet/lang/slim.vim @@ -98,7 +98,10 @@ function! emmet#lang#slim#imageSize() if fn =~ '^\s*$' return elseif fn !~ '^\(/\|http\)' - let fn = simplify(expand('%:h') . '/' . fn) + let fn = resolve(expand(fn)) + if !filereadable(fn) + let fn = simplify(expand('%:h') . '/' . fn) + endif endif let [width, height] = emmet#util#getImageSize(fn) diff --git a/autoload/emmet/util.vim b/autoload/emmet/util.vim index e908534..6f0c6da 100644 --- a/autoload/emmet/util.vim +++ b/autoload/emmet/util.vim @@ -241,11 +241,16 @@ function! emmet#util#getImageSize(fn) endfunction function! emmet#util#imageSizeWithImageMagick(fn) - let img_info = system('identify -format "%wx%h" "'.a:fn.'"') - let img_size = split(substitute(img_info, '\n', '', ''), 'x') - let width = img_size[0] - let height = img_size[1] - return [width, height] + let fn = a:fn + if filereadable(fn) + let img_info = system('identify -format "%wx%h" "'.a:fn.'"') + let img_size = split(substitute(img_info, '\n', '', ''), 'x') + let width = img_size[0] + let height = img_size[1] + return [width, height] + else + echo 'The file "'.fn.'" does not exist or is not readable' + return [-1, -1] endfunction function! emmet#util#isImageMagickInstalled()