From 8fcb1d01334e02e733d6e229243fa52a6f50141f Mon Sep 17 00:00:00 2001 From: tdreyno Date: Mon, 26 Oct 2009 15:08:21 -0700 Subject: [PATCH] automatic image size calculations --- .../features/automatic_image_sizes.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/middleman/features/automatic_image_sizes.rb b/lib/middleman/features/automatic_image_sizes.rb index 9c325823..23b3e6a5 100644 --- a/lib/middleman/features/automatic_image_sizes.rb +++ b/lib/middleman/features/automatic_image_sizes.rb @@ -3,11 +3,11 @@ require "middleman/fastimage" class Middleman::Base alias_method :pre_automatic_image_tag, :image_tag helpers do - def image_tag(path, params={}) - params[:alt] ||= "" - prefix = options.http_images_path rescue options.images_dir - + def image_tag(path, params={}) if (!params[:width] || !params[:height]) && !path.include?("://") + params[:alt] ||= "" + prefix = options.http_images_path rescue options.images_dir + begin real_path = File.join(options.public, asset_url(path, prefix)) if File.exists? real_path @@ -17,11 +17,13 @@ class Middleman::Base end rescue end + + params = params.merge(:src => asset_url(path, prefix)) + params = params.map { |k,v| %Q{#{k}="#{v}"}}.join(' ') + "" + else + pre_automatic_image_tag(path, params) end - - params = params.merge(:src => asset_url(path, prefix)) - params = params.map { |k,v| %Q{#{k}="#{v}"}}.join(' ') - "" end end end \ No newline at end of file