简体   繁体   English

如果在 Rackspace Cloudfiles 中删除图像,会出现默认图像?

[英]Default Image appear if image removed in Rackspace Cloudfiles?

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.疯狂的问题,但我需要/希望能够出现替换图像,使用相同的 url 到云文件图像,以防找不到实际图像。

So in an img tag on someone's blog it would point to an image i host.因此,在某人博客上的 img 标签中,它将指向我托管的图像。 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.如果实际图像不再存在,而不是显示浏览器所做的烦人的带边框的 img 文件,我想显示另一张图像。

In rails using paperclip, we can set a default image, but that is only if the field isn't populated yet.在使用回形针的 rails 中,我们可以设置默认图像,但前提是该字段尚未填充。 It's this thinking i'd like to replicate in real thug life.我想在现实的暴徒生活中复制这种想法。

thoughts?想法?

I made a function similar to this for private branding.我为自有品牌制作了与此类似的 function。 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.每当他们 go 访问 website.com/theircompany 时,它都会显示他们的徽标和登录信息。 I have it displaying their image instead of the server default by a simple If Then in the view.我让它通过一个简单的 If Then 在视图中显示他们的图像而不是服务器默认值。 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?如果这些图像非常小(<1MB),您可以将它们存储在数据库中吗? 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.有一个修改过的 Paperclip gem 可以做到这一点。 I have forked it since I know that this version works perfectly with my server and MySQL.我已经分叉了它,因为我知道这个版本与我的服务器和 MySQL 完美配合。

https://github.com/kobaltz/paperclip https://github.com/kobaltz/paperclip

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM