节点背景图像不起作用(仅显示来自Flickr的图像)

时间:2016-12-06 18:24:58

标签: javascript cytoscape.js

我无法使background-image节点属性生效。

我只是使用"图像&广度布局"演示作为一个测试示例(位于https://gist.github.com/maxkfranz/aedff159b0df05ccfaa5),但我甚至无法让它工作。

在演示中,在' code.js'文件,如果我将任何图像路径更改为staticflickr以外的任何内容,图像将不会显示。例如:

如果我改变

.selector('#bird')
  .css({
    'background-image': 'https://farm8.staticflickr.com/7272/7633179468_3e19e45a0c_b.jpg'
  })

.selector('#bird')
  .css({
    'background-image': 'http://astromatrix.org/Content/Images/Objects/Bird.jpg'
  })

图像在图表中显示为空白灰色(如附图所示)。

我尝试过本地文件,在不同网站上托管多个其他图片,我可以上传的唯一图片来自flickr。

我完全错过了什么吗?

提前致谢

Blank image for bird when I change the image URL from flickr image

1 个答案:

答案 0 :(得分:0)

使用您自己的服务器上拥有的图像。如果服务器没有发回适当的标题,则无法使用图像。

请务必参阅log in the debug console

Access to Image at 'http://astromatrix.org/Content/Images/Objects/Bird.jpg' from origin 'http://astromatrix.org' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8888' is therefore not allowed access.