Tuesday, February 23, 2021

SharePoint Gallery View - Make images of people bigger

The gallery view in SharePoint is great, especially when used to show people.  For example, I've created a New Hire list that is populated by a Powershell script that pulls in any new hires nightly.  But the images for the people are tiny:

But it's SO CLOSE to what we're looking for!

So with a couple of quick edits, you can increase the size of those images.

  • From your Views, select "Format the current view":

And then select on Card Designer, then Advanced Mode


      

Copy the JSON and paste it into an editor.  Do a search for:

"src": "=getUserImage([$personIterator.email], 'S')"

And replace the 'S' with an 'L' to bring back the bigger image.

Next, find the following block:

"forEach": "personIterator in [$NewHire]",
                    "elmType": "a",
                    "attributes": {
                      "class": "=if(loopIndex('personIterator') >= 5, 'sp-card-userContainer', 'sp-card-userContainer sp-card-keyboard-focusable')"
                    },
                    "style": {
                      "display": "=if(loopIndex('personIterator') >= 5, 'none', '')"
                    },

Add a width and height property to the style section to the size that you'd like the image to be:


"forEach": "personIterator in [$NewHire]",
                    "elmType": "a",
                    "attributes": {
                      "class": "=if(loopIndex('personIterator') >= 5, 'sp-card-userContainer', 'sp-card-userContainer sp-card-keyboard-focusable')"
                    },
                    "style": {
                      "display": "=if(loopIndex('personIterator') >= 5, 'none', '')",
      "width": "100px",
      "height": "100px"
                    },

Pasted this JSON back in, save the view and you should be all set!



No comments: