lib/jekyll-bits/picture.rb in jekyll-bits-0.9.1 vs lib/jekyll-bits/picture.rb in jekyll-bits-0.9.2

- old
+ new

@@ -66,10 +66,12 @@ html + '</figure>' end private + @home = nil + def uri(page) uri = '' uri = page['image'] if page['image'] yaml = page['jb_picture'] if yaml @@ -78,14 +80,23 @@ else uri = yaml end end uri = URI.parse(uri) - unless %w(http https).include?(uri.scheme) - home = Jekyll.configuration({})['url'] - uri = home.gsub(%r{/$}, '') + uri.to_s unless home.nil? - end + uri = home + uri.to_s unless %w(http https).include?(uri.scheme) uri.to_s + end + + def home + if @home.nil? + @home = Jekyll.configuration({})['url'] + if @home.nil? + @home = '' + else + @home.gsub!(%r{/$}, '') + end + end + @home end end # Box for testing and calling static methods. class JbBox