Jpu*_*unt 11 ruby ruby-on-rails image-processing paperclip
我想为多种格式使用单个文件字段.据我所知,Paperclip非常聪明,只能缩放图像并保留其他格式,但这似乎不适用于flv(返回imagemagick/identify-errors).有没有办法帮助Paperclip并明确设置特定格式进行扩展?
更新: 显然,这些错误可以通过以下方式防止:whiny => false(感谢fl00r),适用于常规上传.但是,我在这里要做的是通过FTP上传文件,然后通过附件 - 参数中的File.new([:path])的代码创建新记录.这就像是图像的魅力,但是:whiny => false-trick将不再这样做了.有人对此有任何提示吗?
fl0*_*00r 13
将:whiny
选项设置为false:
has_attached_file :my_attach, :whiny => false ...
Run Code Online (Sandbox Code Playgroud)
它不会帮助peparclip仅处理图像,但如果处理失败则不会抛出错误
UPD
仅处理图像:
has_attached_file :file,
:styles => lambda{ |a| ["image/jpeg", "image/png"].include?( a.content_type ) ? { :small => "90x90#" } : {} }
Run Code Online (Sandbox Code Playgroud)
您可以在其中添加更多内容类型到["image/jpeg", "image/png"]
数组中