Skip to content

Commit

Permalink
patched image functions to accept a real path
Browse files Browse the repository at this point in the history
  • Loading branch information
scottdavis committed Jul 28, 2011
1 parent ec7c4b2 commit 289c452
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
12 changes: 10 additions & 2 deletions lib/compass/sass_extensions/functions/image_size.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/compass/sass_extensions/functions/sprites.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def sprite_file(map, sprite)
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
Expand Down

0 comments on commit 289c452

Please sign in to comment.