{"action":"created","issue":{"url":"https://api.github.com/repos/fex-team/ueditor/issues/2590","repository_url":"https://api.github.com/repos/fex-team/ueditor","labels_url":"https://api.github.com/repos/fex-team/ueditor/issues/2590/labels{/name}","comments_url":"https://api.github.com/repos/fex-team/ueditor/issues/2590/comments","events_url":"https://api.github.com/repos/fex-team/ueditor/issues/2590/events","html_url":"https://github.com/fex-team/ueditor/issues/2590","id":135027471,"number":2590,"title":"服务器设置防盗链后编辑器内插入的图片不能显示.","user":{"login":"redspear119","id":2662330,"avatar_url":"https://avatars.githubusercontent.com/u/2662330?v=3","gravatar_id":"","url":"https://api.github.com/users/redspear119","html_url":"https://github.com/redspear119","followers_url":"https://api.github.com/users/redspear119/followers","following_url":"https://api.github.com/users/redspear119/following{/other_user}","gists_url":"https://api.github.com/users/redspear119/gists{/gist_id}","starred_url":"https://api.github.com/users/redspear119/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redspear119/subscriptions","organizations_url":"https://api.github.com/users/redspear119/orgs","repos_url":"https://api.github.com/users/redspear119/repos","events_url":"https://api.github.com/users/redspear119/events{/privacy}","received_events_url":"https://api.github.com/users/redspear119/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-02-20T03:24:11Z","updated_at":"2016-02-20T08:38:43Z","closed_at":null,"body":"我使用SAE作为服务器,开启了防盗链后编辑器内上传图片不能正常显示.镜检查是图片请求没有referer信息导致防盗链阻止了图片显示.\r\n请问ueditor取消lframe的referer的写法是什么考虑?\r\n如何增加正确的referer?\r\n毕竟现在大多数网站都要防盗链的吧.\r\n"},"comment":{"url":"https://api.github.com/repos/fex-team/ueditor/issues/comments/186542920","html_url":"https://github.com/fex-team/ueditor/issues/2590#issuecomment-186542920","issue_url":"https://api.github.com/repos/fex-team/ueditor/issues/2590","id":186542920,"user":{"login":"redspear119","id":2662330,"avatar_url":"https://avatars.githubusercontent.com/u/2662330?v=3","gravatar_id":"","url":"https://api.github.com/users/redspear119","html_url":"https://github.com/redspear119","followers_url":"https://api.github.com/users/redspear119/followers","following_url":"https://api.github.com/users/redspear119/following{/other_user}","gists_url":"https://api.github.com/users/redspear119/gists{/gist_id}","starred_url":"https://api.github.com/users/redspear119/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/redspear119/subscriptions","organizations_url":"https://api.github.com/users/redspear119/orgs","repos_url":"https://api.github.com/users/redspear119/repos","events_url":"https://api.github.com/users/redspear119/events{/privacy}","received_events_url":"https://api.github.com/users/redspear119/received_events","type":"User","site_admin":false},"created_at":"2016-02-20T08:38:43Z","updated_at":"2016-02-20T08:38:43Z","body":"用了一个蛋都能疼死的方式解决了.\r\n因为防盗链是通过referer判断的,,而ueditor使用iframe的src,直接去除了referer的可能性.\r\n貌似这变成了一个无解的两难,要不取消防盗链,要不换编辑器.\r\n哭死了.\r\n-----------------------------\r\n无意间在胡乱尝试的时候,发现物如果插入的是页面上其他地方已经显示过的图片(其实就是网站的logo)的时候,编辑器里神奇的直接显示了图片??\r\n仔细一想,原来网页上应用图片的时候是有referer的,图片已经在缓存里了!\r\n编辑器里面的img是从缓存里获得的图片!!\r\n之下好办了.\r\n直接加一个隐藏的div\r\n```\r\n<div class=\"pure-u-1\" id=\"abc001\">\r\n   \t\t\t\t隐藏的div图片在这里\r\n</div>\r\n```\r\n然后拦截ueditor的事件\r\n      ```\r\n  var  u1=UE.getEditor('pb63inputcontent');\r\n           //侦听图片插入\r\n            u1.addListener('beforeInsertImage', function (t, arg) {\r\n\t\t\t   for(var obj in arg){\r\n                                   //console.log(arg[obj].src);\r\n\t\t\t\t   var vhtml='<br/><img  src=\"'+arg[obj].src+'\"  style=\"width:100%;\"/>';\r\n\t\t\t\t   $(\"#abc001\").append(vhtml);\r\n              };\r\n             });\r\n```\r\n在向编辑器插入图片之前先添加到隐藏的div里,因为div里的图片不违反盗链规则.所以就正常加载了,然后,编辑器里的img标签就从缓存获得图片正常显示了.\r\n--------------------------------------------------------------------\r\n真是一个比蛋碎了还令人心痛的解决方案.\r\n如果需要的,拿去用吧.\r\n别忘了默念:感谢你啊,我亲爱的祖国,党啊,俺滴度娘!\t"}}