Sha256: 77f70ecfed63aa17e0625a6899c216eff3394fa49acaba2778a396736baf5d52

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

module Paperclip
  module Qin
    module ActionViewExtensions
      module QiniuImagePath
        def qiniu_image_path(source, options={})
          options = options.clone
          thumbnail = options.delete(:thumbnail)
          gravity = options.delete(:gravity)
          crop = options.delete(:crop)
          quality = options.delete(:quality)
          rotate = options.delete(:rotate)
          format = options.delete(:format)
          auto_orient = options.delete(:auto_orient)
          res = source
          res += "?imageMogr"
          res += "/thumbnail/#{CGI.escape thumbnail}" if thumbnail
          res += "/gravity/#{CGI.escape gravity}" if gravity
          res += "/crop/#{CGI.escape crop}" if crop
          res += "/quality/#{CGI.escape quality.to_s}" if quality
          res += "/rotate/#{CGI.escape rotate.to_s}" if rotate
          res += "/format/#{CGI.escape format.to_s}" if format
          res += "/auto-orient" if auto_orient
          if res.end_with? '?imageMogr'
            source
          else
            res
          end
        end
      end
    end
  end
end

ActionView::Base.send :include, Paperclip::Qiniu::ActionViewExtensions::QiniuImagePath

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paperclip-new-qiniu-0.1.2 lib/paperclip/qin/action_view_extensions/qiniu_image_path.rb