示例:
<img src="https://twitter.com/mozilla/profile_image">
实时演示:https://jsbin.com/ziwanu/edit?html,output
相应的HTTP请求将cookie发送到Twitter,这就是Firefox的新跟踪保护功能会阻止它的原因,即不显示图像。是否可以通过一种与Firefox的Tracking Protection兼容的方式从Twitter获取个人资料图片?
更新:图像代理可以用作动态后备(通过onerror
属性)。演示:https://jsbin.com/xibose/edit?html,js,output
我认为您可以将几件事链接在一起以执行此操作...
使用Avatars.io,您可以在不询问Twitter的情况下请求用户的图像。
http://avatars.io/twitter/mozilla
或者,查看大图
http://avatars.io/twitter/mozilla?size=large
将重定向到
http://pbs.twimg.com/profile_images/576067580219146242/ON0VuHtK_bigger.png
我不知道您的cookie是否会发送到那里。如果是这样,则可以使用https://images.weserv.nl/之类的图像代理(可以使用其他代理!)。
所以-https://images.weserv.nl/?url=avatars.io%2Ftwitter%2Fmozilla%3Fsize%3Dlarge
我认为这将通过代理加载图像-不发送任何内容到Twitter。
Firefox显然在网络级别上有一个黑名单,在私有浏览时它不允许第三方网站访问:https://developer.mozilla.org/en-US/Firefox/Privacy/Tracking_Protection
因此,在私有浏览模式下,从Twitter加载个人资料图像的唯一方法是通过另一台服务器代理它。