From 4c5b614fe2e58616272cd300b5b023ae9446b272 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Mon, 9 Jul 2012 00:16:54 -0700 Subject: [PATCH] Make :automatic_image_sizes work for absolute image paths --- .../extensions/automatic_image_sizes.rb | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/middleman-more/lib/middleman-more/extensions/automatic_image_sizes.rb b/middleman-more/lib/middleman-more/extensions/automatic_image_sizes.rb index ccc5a6c2..13d98aef 100755 --- a/middleman-more/lib/middleman-more/extensions/automatic_image_sizes.rb +++ b/middleman-more/lib/middleman-more/extensions/automatic_image_sizes.rb @@ -32,25 +32,25 @@ module Middleman def image_tag(path, params={}) if !params.has_key?(:width) && !params.has_key?(:height) && !path.include?("://") params[:alt] ||= "" - http_prefix = http_images_path rescue images_dir - begin - real_path = File.join(source, images_dir, path) - full_path = File.expand_path(real_path, root) - http_prefix = http_images_path rescue images_dir - if File.exists? full_path - dimensions = ::FastImage.size(full_path, :raise_on_failure => true) - params[:width] = dimensions[0] - params[:height] = dimensions[1] + real_path = path + real_path = File.join(images_dir, real_path) unless real_path =~ %r{^/} + full_path = File.join(source_dir, real_path) + + if File.exists? full_path + begin + width, height = ::FastImage.size(full_path, :raise_on_failure => true) + params[:width] = width + params[:height] = height + rescue + warn "Couldn't determine dimensions for image #{path}: #{$!.message}" end - rescue - # $stderr.puts params.inspect end end - + super(path, params) end end end end -end \ No newline at end of file +end