热链接图像上有水印吗?
我想知道是否可以在外部站点上的热链接图像上有水印,但在原始站点上却没有水印?我正在使用 jQuery,我可以对此做些什么吗?
多谢多谢!
I wonder if its possible to have a watermark on hotlinked images on an external site, but not on the original site? I'm using jQuery, can I do something about this?
Thanks heaps!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
通过客户端技术这是不可能的。您将需要基于服务器。
如果您可以使用服务器端技术,例如 ASP.NET;您可以通过 ashx 处理程序公开所有图像。这可以让您在某些图像上显示水印,或者根本不显示图像,具体取决于来源。
这是一篇关于为图像编写 ashx 处理程序的精彩文章 --
http://dotnetperls.com/ashx-handler /https ://web.archive.org/web/20160311222240/http://www.dotnetperls.com/ashx-handler如果您使用的是基于 *nix 的服务器,@Jojo 有一些使用 php 进行类似操作的链接影响。
在 ASP.NET 或 php 中编写此类处理程序后,您需要检查 HTTP Referer 以查看它是否是您网站或第三方网站上的页面,然后进行必要的图像处理以产生水印效果。
This is not possible through a client-side technology. You will need to go server based.
If you have access to a server side technology, such as ASP.NET; you could expose all of your images through an ashx handler. This would let you display a water mark on some images, or not display images at all depending on the source.
Here's a great article on writing ashx handlers for images --
http://dotnetperls.com/ashx-handler/https://web.archive.org/web/20160311222240/http://www.dotnetperls.com/ashx-handlerIf you are using a *nix based server, @Jojo has some links for using php to similar effect.
After writing such a handler in ASP.NET or php, you'll need to check the HTTP Referer to see if it is a page on your site, or a third party site and then do the necessary image processing to produce your watermakr effect.
在运行水印代码之前,您需要检查引荐来源网址 HTTP 标头是否与您网站的域匹配,以确定是否需要水印。
You would need to check that the referrer HTTP header matches your site's domain prior to running the watermarking code to determine whether a watermark is required.
您无法使用 JQuery 执行此操作,因为当通过热链接提供图像时,它根本不涉及。您需要在服务器端执行此操作。
You can't do that with JQuery, since it is not at all involved when the image is served via hotlink. You'll need to do it server-side.
您必须在后端执行某些操作才能为热链接图像添加水印。
如果您可以访问 PHP,请查看本文。
You would have to do something on the back-end to add a watermark to hot-linked images.
Check out this article if you have access to PHP.