1

回形针宝石 3.0.4

当我在模型中使用平面回形针定义时(UserDetail 有一个头像):

has_attached_file :avatar, :styles => {:medium =>  "300x300>", : :thumb => "64x64#" }

所有图像均以正确的比例创建。

当我通过 lambda ( http://www.matthuggins.com/articles/rotating-paperclip-image-attachments-in-rails ) 使用自定义处理器时:

has_attached_file :avatar, :processors => [:rotator], :styles => lambda { |a| {
  :thumb => { :geometry => '64x64#', :rotation => a.instance.rotation, },
  :medium => { :geometry => '300x300>', :rotation => a.instance.rotation, },  } }

图像旋转了指定的量,但所有图像都保持与 :original 相同的大小和比例。

:geometry 是正确的参数吗?这在后来的 Paperclip 版本中是否发生了变化(我不确定 Web 示例中使用的 Paperclip 版本)?

感激地收到任何指示

问候

彼得

4

1 回答 1

0

每种风格一个过程:

has_attached_file :avatar, 
  :processors => [:rotator], 
  :styles => {
    :thumb =>  Proc.new { |a| { :geometry => '64x64#', :rotation => a.instance.rotation } },
    :medium => Proc.new { |a| { :geometry => '300x300>', :rotation => a.instance.rotation } } 
  }
于 2012-05-28T19:45:13.813 回答