From f2538f2e54ba4ee9ce31fb754b1e6cd5a9251815 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Sun, 22 Sep 2013 14:02:51 -0700 Subject: [PATCH] Look for assets using url_for before falling back to the "images" directory --- .../core_extensions/default_helpers.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb b/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb index b0353ab3..84d6f645 100644 --- a/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb +++ b/middleman-core/lib/middleman-more/core_extensions/default_helpers.rb @@ -13,7 +13,7 @@ if !defined?(::Padrino::Helpers) require 'vendored-middleman-deps/padrino-core-0.11.2/lib/padrino-core/support_lite' require 'vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers' end - + class Padrino::Helpers::OutputHelpers::ErbHandler # Force Erb capture not to use safebuffer def capture_from_template(*args, &block) @@ -176,11 +176,15 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension if path.include?('//') or path.start_with?('data:') path else # rewrite paths to use their destination path - path = File.join(prefix, path) - if resource = sitemap.find_resource_by_path(path) + if resource = sitemap.find_resource_by_destination_path(url_for(path)) resource.url else - File.join(config[:http_prefix], path) + path = File.join(prefix, path) + if resource = sitemap.find_resource_by_path(path) + resource.url + else + File.join(config[:http_prefix], path) + end end end end