开发者

Paperclip - exclude zip, rar from cropping

I have an Attachment model, which is using Paperclip to handle uploaded files. The file can be anything an image, a txt, doc, pdf, rar, zip, tar etc.

I want t开发者_StackOverflow中文版o create thumbnails only if the file uploaded is an image.

How to create thumbnails in Paperclip conditionally based upon file content_type


This is a nice solution:

before_post_process :image?
def image?
  !(data_content_type =~ /^image.*/).nil?
end

You can also use the image? method in your views to either render an image_tag, or something else...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜