Module: Sinatra::Thumbnails::Helpers

Defined in:
lib/sinatra/thumbnails.rb

Instance Method Summary collapse

Instance Method Details

#thumbnail_url_for(asset, format = Thumbnails.settings.thumbnail_format) ⇒ Object



88
89
90
91
92
# File 'lib/sinatra/thumbnails.rb', line 88

def thumbnail_url_for(asset, format = Thumbnails.settings.thumbnail_format)
  almost_original = asset.gsub(/(.*\.)(.*$)/,"\\1#{Thumbnails.settings.thumbnail_extension}")
  original_extension = Regexp.last_match(2)
  "#{Thumbnails.settings.thumbnail_path}/#{format}/#{almost_original}?original_extension=#{original_extension}"
end