0

I have added JSON-code to my list column "Person" which displays the persons name and profile picture. But it doesn't show my profile picture. What do i do wrong?

{
 "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
    "elmType": "div",
    "style": {
        "flex-direction": "column",
  "align-items": "flex-start",
  "margin-top": "6px",
  "padding-right": "8px",
  "width": "100%",
  "overflow": "hidden"
    },
 "children": [{
  "forEach": "personIterator in @currentField",
  "elmType": "div",
  "attributes": {
   "class": "ms-bgColor-neutralLight ms-fontColor-neutralSecondary"
  },
  "style": {
   "display": "inline-flex",
   "align-items": "center",
            "height": "28px",
            "overflow": "hidden",
   "border-radius": "12px",
   "padding-right": "8px",
   "margin": "2px"
  },
  "children": [
            {
    "elmType": "img",
    "attributes": {
     "src": "='/_layouts/15/userphoto.aspx?size=S&accountname=' + [$personIterator.email]",
     "title": "[$personIterator.title]"
    },
    "style": {
     "width": "28px",
     "height": "28px",
     "display": "block",
     "border-radius": "50%"
    }
   },
   {
                "elmType": "div",
                "txtContent": "[$personIterator.title]",
                "attributes": {
                    "title": "[$personIterator.title]",
                    "class": "nameplate-title"
                },
                "style": {
                    "padding-left": "5px",
                    "white-space": "nowrap",
                    "font-size": "12px"
                }
            }
  ],
  "defaultHoverField": "[$personIterator]"
 }]
}
2
  • First try manually running the URL generated in src attribute and see if it is referring to correct picture URL. Commented Feb 28, 2021 at 17:38
  • I have run the url and it download the placeholder. Commented Feb 28, 2021 at 17:46

1 Answer 1

1

I tried using above JSON code in my SharePoint tenant and it is working fine for person or group column (with multiple selection allowed).

Also, you don't need to use JSON for showing profile picture along with person name in list view. You can achieve this using out of the box column settings (with new feature in SharePoint).

Follow below steps:

  1. Go to SharePoint list & click on small dropdown next to column header.
  2. Select Column settings and then Edit.

enter image description here

  1. Change Show profile photos to Yes.
  2. Click Save

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.