Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions core/lib/compass/core/sass_extensions/functions/image_size.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def image_width(image_file)
width, _ = image_dimensions(image_file)
number(width, "px")
end

# Returns the height of the image relative to the images directory
def image_height(image_file)
_, height = image_dimensions(image_file)
Expand All @@ -15,7 +15,13 @@ def image_height(image_file)

class ImageProperties
def initialize(file)
@file = (file.respond_to?(:to_path) ? file.to_path : file)
@file = if file.respond_to?(:to_path)
file.to_path
elsif file.respond_to?(:filename)
file.filename
else
file
end
@file_type = File.extname(@file)[1..-1].downcase
unless KNOWN_TYPES.include?(@file_type)
raise Sass::SyntaxError, "Unrecognized file type: #{@file_type}"
Expand Down Expand Up @@ -53,10 +59,10 @@ def image_dimensions(image_file)
options[:compass][:image_dimensions] ||= {}
options[:compass][:image_dimensions][image_file] = ImageProperties.new(image_path_for_size(image_file)).size
end

def image_path_for_size(image_file)
if File.exists?(image_file)
return image_file
return image_file
end
real_path(image_file)
end
Expand Down