ruby-on-rails – 蜻蜓宝石 – 默认图像?
发布时间:2020-12-17 03:53:00 所属栏目:百科 来源:网络整理
导读:我正在使用Dragonfly并希望有一个默认图像,其缩放方式与缩略图相同. 我目前有以下代码,但是当Dragonfly使用fetch_file方法时,它会尝试处理缩略图,但生成的URL是一个死链接. if listing.image image = listing.image.jpgelse image = Dragonfly[:images].fetc
我正在使用Dragonfly并希望有一个默认图像,其缩放方式与缩略图相同.
我目前有以下代码,但是当Dragonfly使用fetch_file方法时,它会尝试处理缩略图,但生成的URL是一个死链接. if listing.image image = listing.image.jpg else image = Dragonfly[:images].fetch_file('/toekomst/images/speech-bubble.png') end image_tag image.jpg.thumb(size).url,:class => "framed" 我在这方面找不到多少帮助,所以任何提示都非常感谢!谢谢! 解决方法
您需要将配置值’allow_fetch_file’设置为true – 默认情况下,使用fetch_file通过服务器请求安全性(这里没有特别说明,除了这里:
http://markevans.github.com/dragonfly/Dragonfly/Server.html 但是,如果你这样做,你可能应该将’protect_from_dos_attacks’打开为true,再次为安全起见: Dragonfly[:images].configure do |c| # ... c.allow_fetch_file = true c.protect_from_dos_attacks = true c.secret = "some secret here..." end 希望有所帮助 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |