Back to column formats
Column formattingSharePoint Online

File Thumbnails

Utilizes the @thumbnail placeholder token to create an inline preview for document libraries.

File Thumbnails formatting preview
Sample preview · View original animation

Copy. Apply. Make it yours.

Get this format

2 definitions

Review the requirements below, then paste this JSON into the matching formatting panel. Show me where.

Use your list's internal column names and replace any tenant-specific URLs or flow IDs. Formatting is presentation, not a way to secure data.

Column formatting
Download JSON
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "style": {
    "margin": "5px",
    "display": "flex",
    "justify-content": "center",
    "width": "100%"
  },
  "children": [
    {
      "elmType": "img",
      "style": {
        "cursor": "pointer"
      },
      "attributes": {
        "src": "@thumbnail.50"
      },
      "customCardProps": {
        "directionalHint": "rightCenter",
        "openOnEvent": "hover",
        "isBeakVisible": true,
        "formatter": {
          "elmType": "div",
          "style": {
            "width": "520px",
            "height": "520px",
            "padding": "10px",
            "display": "flex",
            "justify-content": "center",
            "align-items": "center"
          },
          "children": [
            {
              "elmType": "img",
              "attributes": {
                "src": "@thumbnail.500"
              }
            }
          ]
        }
      }
    }
  ]
}

From the contributor

How to use this sample

Summary

This sample utilizes the @thumbnail placeholder token to create an inline preview for document libraries. Folders and filetypes where previews are not available will not display at all.

screenshot of the sample

file-thumbnail-lightbox.json displays enlarged thumbnails in a lightbox. This sample is derived from image-lightbox.

screenshot of the sample

Note - the automatic removal of the img element when dealing with folders or filetypes where previews are not available requires that properties of the img element do not use expressions.

View requirements

This can be added on any column in a document library, overwriting its contents.

Sample

Solution Author(s)
file-thumbnail.json Chris Kent
file-thumbnail-lightbox.json Tetsuya Kawahara

Version history

Version Date Comments
1.0 May 27, 2019 Initial release
1.1 July 4, 2021 Added file-thumbnail-lightbox.json

Disclaimer

THIS CODE IS PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.


Additional notes

  • SharePoint Online only