patched image functions to accept a real path

This commit is contained in:
Scott Davis 2011-07-27 21:31:56 -04:00
parent ec7c4b2e9c
commit 289c452d64
3 changed files with 12 additions and 4 deletions

View File

@ -1,7 +1,7 @@
PATH PATH
remote: . remote: .
specs: specs:
compass (0.12.0.alpha.0.8c48248) compass (0.12.0.alpha.0.ec7c4b2)
chunky_png (~> 1.2) chunky_png (~> 1.2)
fssm (>= 0.2.7) fssm (>= 0.2.7)
sass (~> 3.1) sass (~> 3.1)

View File

@ -1,14 +1,22 @@
module Compass::SassExtensions::Functions::ImageSize module Compass::SassExtensions::Functions::ImageSize
# Returns the width of the image relative to the images directory # Returns the width of the image relative to the images directory
def image_width(image_file) 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 width = ImageProperties.new(image_path).size.first
Sass::Script::Number.new(width,["px"]) Sass::Script::Number.new(width,["px"])
end end
# Returns the height of the image relative to the images directory # Returns the height of the image relative to the images directory
def image_height(image_file) 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 height = ImageProperties.new(image_path).size.last
Sass::Script::Number.new(height, ["px"]) Sass::Script::Number.new(height, ["px"])
end end

View File

@ -61,7 +61,7 @@ module Compass::SassExtensions::Functions::Sprites
verify_map(map, "sprite") verify_map(map, "sprite")
verify_sprite(sprite) verify_sprite(sprite)
if image = map.image_for(sprite.value) if image = map.image_for(sprite.value)
Sass::Script::String.new(image.relative_file) Sass::Script::String.new(image.file)
else else
missing_image!(map, sprite) missing_image!(map, sprite)
end end