pnp / List-Formatting

List Formatting Samples for use in SharePoint and Microsoft Lists
https://pnp.github.io/List-Formatting/
MIT License
1.74k stars 834 forks source link

Image - Gallery Sample #562

Closed chris883773 closed 1 year ago

chris883773 commented 2 years ago

Hello,

i am looking for a sample looks like this: image

I have a document library with only images. image

It is possible to write a json to create something like the sample picture?

aaclage commented 2 years ago

@chris883773 You can create a Gallery view and test bellow formatting, the key to appear as you want it's define on the max width or max height to assume the size of the original images. Its important that you define a max that you manage the size of image, some can be huge...

Sample formatting:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/tile-formatting.schema.json",
  "formatter": {
    "elmType": "div",
    "style": {
      "padding": "20px 5px "
    },
    "children": [
      {
        "elmType": "img",
        "attributes": {
          "src": "[$FileRef]"
        },
        "style": {
          "cursor": "pointer",
          "border-radius": "15px",
          "max-width": "200px",
          "max-height": "100px"
        }
      }
    ]
  }
}