1

ペーパークリップの宝石3.0.4

モデルでフラットペーパークリップ定義を使用する場合(UserDetailにはアバターがあります):

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

すべての画像は正しい比率で作成されます。

ラムダ( 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

スタイルごとに1つのproc:

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 に答える