You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过JSON将SharePoint列表人物列头像调整为72x72?

SharePoint Gallery视图中调整Person列头像尺寸为72x72像素的正确JSON代码

你之前的JSON代码存在语法错误,导致无法生效,正确的列格式化代码如下:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "style": {
    "width": "72px",
    "height": "72px",
    "overflow": "hidden",
    "border-radius": "50%"
  },
  "children": [
    {
      "elmType": "img",
      "attributes": {
        "src": "@currentField.picture",
        "title": "@currentField.title"
      },
      "style": {
        "width": "100%",
        "height": "100%",
        "object-fit": "cover"
      }
    }
  ]
}

使用步骤:

  • 打开目标SharePoint列表,切换到Gallery视图
  • 找到需要调整的Person列,点击列标题旁的下拉箭头,选择「列设置」→「格式化此列」
  • 在弹出的格式化面板中,切换到「高级模式」,替换原有代码为上面的JSON,保存即可

代码说明:

  • 外层div固定72x72像素的容器尺寸,border-radius: 50%用于实现圆形头像(不需要可删除该行)
  • 内部img元素设置100%宽高,object-fit: cover保证头像按比例填充容器,避免拉伸变形
  • 自动读取Person列的头像地址和用户名称作为图片的src和title属性

你之前代码的问题:

  1. 语法错误:"height""72px"缺少冒号,正确写法是"height": "72px"
  2. 属性分隔错误:多个CSS属性之间需用逗号(,)分隔,而非分号(;)
  3. 结构缺失:SharePoint列格式化需要遵循指定的JSON schema结构,仅单独写宽高属性无法被识别

内容的提问来源于stack exchange,提问作者user1903995

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 00:27:06