Sha256: 12c3c32e039f1d95f633e94f91b37b948191dbcdb1a3b6b376d3d6770b1f792c
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
require "uri" module RailsImager::ImagesHelper def rails_imager_p(path, args = {}) if path.class.name == "Paperclip::Attachment" raise "Paperclip path does not start with public path." unless path.path.to_s.start_with?(Rails.public_path.to_s) path_without_public = path.path.to_s.gsub("#{Rails.public_path}/", "") raise "Path didn't change '#{path.path}' - '#{path_without_public}'." if path.path.to_s == path_without_public path = path_without_public end # Check for invalid parameters. args.each do |key, val| raise ArgumentError, "Invalid parameter: '#{key}'." unless RailsImager::ImageHandler::PARAMS_ARGS.include?(key) end newpath = "/rails_imager/images/" newpath << URI.encode(path) newpath << "/?" first = true args.each do |key, val| if first first = false else newpath << "&" end realkey = "image[#{key}]" newpath << URI.encode(realkey.to_s) newpath << "=" newpath << URI.encode(val.to_s) end return newpath end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rails_imager-0.0.13 | app/helpers/rails_imager/images_helper.rb |
rails_imager-0.0.12 | app/helpers/rails_imager/images_helper.rb |