Rails 和 Paperclip,使用不同的图像,而不是上传的图像进行处理
我想知道有没有一种方法可以为回形针处理的图像指定不同的图像?
因此,不是用户上传图像,而是使用图像 url,或者认为可以指向服务器上现有的不同图像?
干杯。
编辑: 需要明确的是,我正在寻找的是,当图像被上传、处理、移动到文件夹并附加到文件夹时。该基本图像不是通过表单上传的,而是从 URL 中获取并进行处理、移动等。
I was wondering there was a way to specify a different image for the one to be processed by paperclip?
So instead of the user uploading an image, an image url would be used instead or an exsiting different image on your server thought could just be pointed to?
Cheers.
Edit:
Just to be clear, what I'm looking for is, when an image is uploaded, processed, moved to a folder and attached to a folder. That base image is not uploaded via a form but instead is fetched from a URL and them processed, moved etc
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是使用 RemoteFile 而不是上传文件的方法...查看博客文章,了解如何创建 RemoteFile,它是 TempFile 的子类
http://coryodaniel.com/index.php/2010/03/05/attaching-local-or-remote-files-to-paperclip-and-milton-models-in-rails-mocking-content_type-and-original_filename -在临时文件中/
Here's a method to use a RemoteFile instead of an uploaded file... Check out the blog post for how to create a RemoteFile, which is a subclass of TempFile
http://coryodaniel.com/index.php/2010/03/05/attaching-local-or-remote-files-to-paperclip-and-milton-models-in-rails-mocking-content_type-and-original_filename-in-a-tempfile/
我不确定您的要求是否要求用户提供此图像,但如果他们不提供此图像,有一种方法可以拥有默认图像。这是使用 default_url 和默认样式选项完成的,如下所示:
I'm not sure if your requirement is for the user to provide this image or not, but there is a way to have a default image if they don't provide one. This is done using the default_url and default style options like so: