From 289c452d648764284d39beaa8e75d58ea5e85f62 Mon Sep 17 00:00:00 2001 From: Scott Davis Date: Wed, 27 Jul 2011 21:31:56 -0400 Subject: [PATCH] patched image functions to accept a real path --- Gemfile.lock | 2 +- lib/compass/sass_extensions/functions/image_size.rb | 12 ++++++++++-- lib/compass/sass_extensions/functions/sprites.rb | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index aaf6f1eb..a3433dd2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - compass (0.12.0.alpha.0.8c48248) + compass (0.12.0.alpha.0.ec7c4b2) chunky_png (~> 1.2) fssm (>= 0.2.7) sass (~> 3.1) diff --git a/lib/compass/sass_extensions/functions/image_size.rb b/lib/compass/sass_extensions/functions/image_size.rb index 175d3dba..0490e703 100644 --- a/lib/compass/sass_extensions/functions/image_size.rb +++ b/lib/compass/sass_extensions/functions/image_size.rb @@ -1,14 +1,22 @@ module Compass::SassExtensions::Functions::ImageSize # Returns the width of the image relative to the images directory def image_width(image_file) - image_path = real_path(image_file) + image_path = if File.exists?(image_file.value) + image_file.value + else + real_path(image_file) + end width = ImageProperties.new(image_path).size.first Sass::Script::Number.new(width,["px"]) end # Returns the height of the image relative to the images directory def image_height(image_file) - image_path = real_path(image_file) + image_path = if File.exists?(image_file.value) + image_file.value + else + real_path(image_file) + end height = ImageProperties.new(image_path).size.last Sass::Script::Number.new(height, ["px"]) end diff --git a/lib/compass/sass_extensions/functions/sprites.rb b/lib/compass/sass_extensions/functions/sprites.rb index d006d3ee..d2f74b61 100644 --- a/lib/compass/sass_extensions/functions/sprites.rb +++ b/lib/compass/sass_extensions/functions/sprites.rb @@ -61,7 +61,7 @@ module Compass::SassExtensions::Functions::Sprites verify_map(map, "sprite") verify_sprite(sprite) if image = map.image_for(sprite.value) - Sass::Script::String.new(image.relative_file) + Sass::Script::String.new(image.file) else missing_image!(map, sprite) end