开发者

Simplest way to add a thumb size to a model using Paperclip in Rails

I have a Rails model that uses Paperclip and has many thumb sizes. I would like to add a new thumb size and generate ONLY that size if possible - it it completely unnecessary to regenerate all of the old thumbs again. Something like Photo.find(123).photo.reprocess!(:new_size) would be perfect but unfortunately doesn't exist. Anyone know a simple way to achieve this?

Thanks.开发者_开发技巧


The thumb-size can be set in the model of your pictures (see paperclip):

class User < ActiveRecord::Base
  has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }
end

As far as I remember it should be possible to regenerate by deleting the old thumbnails. However, there's also a rake-task for it:

rake paperclip:refresh CLASS=YourModelName


the answer is in the rake task

paperclip:refresh:missing_styles

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜