如果在 Rackspace Cloudfiles 中删除图像,会出现默认图像吗?
疯狂的问题,但我需要/希望能够使用与 cloudfiles 图像相同的 url 来显示替换图像,以防找不到实际图像。
因此,在某人博客上的 img 标签中,它将指向我托管的图像。如果实际图像不再存在,我想显示另一张图像,而不是显示浏览器执行的令人讨厌的带边框的 img 文件。
在使用回形针的 Rails 中,我们可以设置默认图像,但前提是该字段尚未填充。我想在现实的暴徒生活中复制这种想法。
想法?
Wild question, but I need/want the ability to have a replacement image appear, using the same url to a cloudfiles image, incase that actual image can't be found.
So in an img tag on someone's blog it would point to an image i host. if the actual image isn't there anymore, instead of showing that annoying bordered img file that browser's do, i'd like to show another image.
In rails using paperclip, we can set a default image, but that is only if the field isn't populated yet. It's this thinking i'd like to replicate in real thug life.
thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我为自有品牌制作了一个与此类似的功能。用户可以上传自己的徽标来替换我网站的徽标。每当他们访问 website.com/theircompany 时,都会显示他们的徽标和登录信息。我让它通过视图中的简单 If then 显示它们的图像,而不是服务器默认图像。我查看该“公司”是否上传了图片。如果是,则显示他们的图像。如果没有,则显示服务器默认值。
更新:根据您下面的评论,我知道这可能是一个问题。如果这些图像相当小(<1MB),您可以将它们存储在数据库中吗?这就是我目前在服务器上处理图像的方式,听起来这对你有用。有一个经过修改的回形针宝石可以实现这一点。我已经分叉了它,因为我知道这个版本与我的服务器和 MySQL 完美配合。
https://github.com/kobaltz/paperclip
I made a function similar to this for private branding. The user can upload their own logo to replace my website's logo. Whenever they go to website.com/theircompany it will show their logo and login information. I have it displaying their image instead of the server default by a simple If Then in the view. I look to see if that 'company' has an image uploaded. If it does then display their image. If it does not then display the server default.
UPDATE: Based on your comment below, I see where that can be an issue. If these images will be rather small (<1MB) could you store them in a database? That is how I'm currently handling the images on my server and it sounds like that could work for you. There is a modified Paperclip gem that will allow this. I have forked it since I know that this version works perfectly with my server and MySQL.
https://github.com/kobaltz/paperclip