As in the image above, the JSON below essentially adds a column to a Documents library which displays:
- An ‘Extract here’ link for .zip files. Clicking on it runs a Flow in Power Automate to extract the contents to a new folder in the current location
- A thumbnail for .png, .jpg, .gif, and .jpeg files. Clicking on the thumbnail reveals a pop-up of the image with an ‘Open in new window’ button at bottom right. Double-clicking on the thumbnail opens the image as a slide-show
To add this column across libraries in your tenant you’ll need to:
- Add a zip file, image, folder, and Office document to a test library on a SharePoint site (3 minutes)
- Create a Flow in Power Automate and grab its ID from the URL (30 minutes)
- Add your flow ID to the JSON template and paste it into a single-line text column’s formatting pane (5 minutes)
- If it’s working as expected, run the PowerShell script template to roll it out across selected libraries in your tenant (1 minute per library)
1. Set up a Test Library
Head to a library on your tenant and upload a couple of images – in jpg, png, gif, or jpeg format – and a zip file so we can make sure the actions work as expected. Then perhaps add a folder and a Word document to ensure the actions don’t display for these file types.
2. Create the ‘Extract here’ Flow
First follow WonderLaura’s guidance on triggering a flow from multiple SharePoint libraries (when copy/pasting the code you’ll need to swap out the right/left quote marks with normal ones). Once you’ve added the penultimate step, instead of adding an approvals step add an ‘Extract to folder’ step entering the following into each of the fields:
Site address: Add varSite as a dynamic input
Source file path: add body('Get_file_properties')?['FullPath']
as an expression
Destination Folder Path: add body('Get_file_properties')?['Path']
and body('Get_file_properties')?['Name']
as expressions with no spaces between then.
Your step should look like this:

Finally grab the flow ID from the URL or click Export/Get flow identifier from the details page and paste it into Notepad:

3. Format a Text Column
Head back to your test library and add a single-line text column called ‘Actions’. Click on the column title, ‘Format this column’, then ‘Advanced formatting’:

Copy the following code into notepad, then replace the highlighted text with the ID of your flow from Step 2 above:
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"children": [
{
"elmType": "span",
"children": [
{
"elmType": "span",
"attributes": {
"iconName": "Flow"
},
"style": {
"display": "=if([$File_x0020_Type] == 'zip', '', 'none')"
}
},
{
"elmType": "button",
"txtContent": "Extract here",
"style": {
"border": "none",
"background-color": "transparent",
"color": "#0078d7",
"cursor": "pointer",
"display": "=if([$File_x0020_Type] == 'zip', '', 'none')"
},
"customRowAction": {
"action": "executeFlow",
"actionParams": "{\"id\": \"replace this text with your flow ID\"}"
}
}
]
},
{
"elmType": "filepreview",
"style": {
"width": "0",
"height": "0",
"overflow": "hidden",
"padding": "5px",
"margin-top": "5px",
"display": "=if([$File_x0020_Type] == 'png', '', if([$File_x0020_Type] == 'jpg', '', if([$File_x0020_Type] == 'gif', '', if([$File_x0020_Type] == 'jpeg', '', 'none'))))"
},
"attributes": {
"title": "@Title"
},
"children": [
{
"elmType": "img",
"style": {
"cursor": "pointer",
"margin": "5px 0 0 0"
},
"attributes": {
"src": "@thumbnail.64x64"
},
"customCardProps": {
"formatter": {
"elmType": "div",
"style": {
"padding": "8px",
"background-color": "#fcfcfc"
},
"children": [
{
"elmType": "img",
"attributes": {
"src": "@thumbnail.500x500",
"title": "@Name"
},
"style": {
"background-color": "#e6e6e6"
}
},
{
"elmType": "a",
"attributes": {
"iconName": "OpenInNewWindow",
"href": "@thumbnail.3000x2000",
"target": "_blank",
"class": "ms-bgColor-black ms-fontColor-white ms-fontColor-themeLight--hover",
"title": "Open in New Window"
},
"style": {
"font-size": "18px",
"text-decoration": "none",
"position": "absolute",
"right": "2px",
"bottom": "2px",
"padding": "8px"
}
}
]
},
"openOnEvent": "click",
"directionalHint": "rightCenter",
"isBeakVisible": true,
"beakStyle": {
"backgroundColor": "black"
}
}
}
]
}
]
}
Save the formatting, refresh the page, and test the result:
- Are thumbnails showing for the images, when you click on them a large-pop up appears, and when you double click on them the slide show appears?
- Are ‘Extract here’ links showing for zip files? Does the flow panel pop up on the right when ‘Extract here’ is clicked on and extract the zip file to a new folder in the same folder?
- Are folders and other files showing a blank?
If so, fantastic, we can roll this out to other libraries – so long as they have the same name (every site has a ‘Documents’ library by default). If you’ve only a few it should be faily easy to head to each and simply repeat this step; if you’re rolling this out on more than say ten sites, and have rights to use PnP Powershell, head to Step 4….
4. Rollout to Multiple Libraries using Powershell
To roll this out to multiple libraries copy the code below into Notepad, replace the highlighted text with your own values, copy the code, open your PowerShell console and paste the code in to connect to a site, add the column, and JSON formatting to it:
Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/SiteTitle" -Interactive -ClientId your-client-id
$library = Get-PnPList -Identity "Shared Documents"
Add-PnPField -List $true
$folderPathFormatting = @"
Insert JSON formatting from Step 3 here
"@
The feature stands on the shoulders of the Image Lightbox column formatting sample by João Ferreira and Chris Kent – modified to work in a text column – and WonderLaura’s wonderful guidance on Triggering a Flow from Multiple SharePoint Libraries, modified to perform a zip file extraction action rather than generate an approval flow. Big hat-tip to them!
You might want to add additional actions for other file or content types too – perhaps you have a content type that requires an approvals step, or a data file that refreshes a Power BI report for instance. Add another div to the JSON then specify the condition and how it should be displayed. Watch you don’t create a conflict mind 8^)
Ready to transform your SharePoint experience? Implement this solution today and share your results in the comments below – or tag us in your LinkedIn post showing your improved libraries! Suggestions for improvements that would work generically for most organisations welcome.
Discover more from Information Handyman
Subscribe to get the latest posts sent to your email.