列表视图格式引用来自外部域的 url,例如推特或 Instagram

问题描述 投票:0回答:1

我正在尝试使用列表视图格式来显示保存在“mediaUrl”列中的图像 URL 作为图像。

我正在使用这个 JSON:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "hideSelection": true,
  "hideColumnHeader": true,
  "rowFormatter": {
    "elmType": "div",
    "style": {
      "position": "relative",
      "text-align": "left",
      "display": "block",
      "font-family": "Segoe UI",
      "background-color": "#F3F2F1",
      "padding": "10px 10px"
    },
    "children": [
      {
        "elmType": "div",
        "style": {
          "display": "flex",
          "box-shadow": "0 3px 6px 0 #00000029"
        },
        "children": [
          {
            "elmType": "div",
            "style": {
              "width": "100%",
              "display": "flex",
              "justify-content": "center",
              "overflow": "hidden",
              "background-color": "#e1dfdd"
            },
            "children": [
              {
                "elmType": "div",
                "style": {
                  "display": "=if([$media_type] == 'IMAGE', 'block', 'none')"
                },
                "children": [
                  {
                    "elmType": "img",
                    "style": {
                      "height": "auto",
                      "max-width": "100%",
                      "flex-shrink": "0"
                    },
                    "attributes": {
                      "src": "[$mediaUrl]"
                    }
                  }
                ]
              }
            ]
          }
        ]  
      }
    ]
  }
}



However any images from external domains, e.g. `https://twitter.com/reshmeeauckloo/photo` won't load except if the URL references an image within the SharePoint site. I have not seen any restrictions around it. Any pointers or help would be appreciated.

I was expecting `src` set to  `https://twitter.com/reshmeeauckloo/photo` for the `img` tag would load/render.
json image sharepoint sharepoint-online
1个回答
0
投票

首先,您必须在 JSON 中使用公共 URL,以便所有用户都有权查看图像。

此外,随着 SharePoint JSON 格式的最新更新,SharePoint JSON 格式中引用的外部图像可能无法工作。

您可以通过在 HTML 字段安全 设置中添加您正在使用图像的外部站点域来解决此问题 - 允许或限制在 SharePoint 页面上嵌入内容的能力

参考如何在不使用编辑网格视图的情况下自动加载URL图像链接

© www.soinside.com 2019 - 2024. All rights reserved.