SOLVED

SharePoint Online JSON column formatting on image column.

Copper Contributor

Hi all,

 

I have a few images saved in a document library, and i also have a list that contains an image column. When an item is created they select the image from the gallery to add to the list item. My question is how can i format the image column using JSON in my list to show the image not the link or name of the image? 

 

Thanks 

4 Replies
best response confirmed by Jay L (Copper Contributor)
Solution

Hi @Jay L  the JSON code for formatting the image column is:

{
"elmType": "img",
"style": {
"width": "100px"
},
"attributes": {
"src": "@currentField"
}
}

 

imageColumn.png

 

If you want to make it clickable then the JSON is:

{
"elmType": "a",
"attributes": {
"href": "@currentField",
"target": "_blank"
},
"children": [
{
"elmType": "img",
"style": {
"width": "150px"
},
"attributes": {
"src": "@currentField"
}
}
]
}

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User

@RobElliott Thanks for your response! Is the image column you're using a hyperlink or picture? I have mine set to picture and the image comes in as shown below: 

 

@Jay L it's a hyperlink column set as Picture type:

imageColumn-type.png

Make sure you are saving the images in an asset library on the site. And copy the link to each one from the menu:

 

imageColumn-url.png

 

Rob

 

@RobElliott Ah i see what I was doing wrong, I was capturing the link to the image via 'Copy Link' from the ellipsis menu. Changed the url to the image to: https://tenant.sharepoint.com/sites/sitename/SiteAssets/Locations/Corporate.png

and it worked.

 

Thanks for your help Rob!

1 best response

Accepted Solutions
best response confirmed by Jay L (Copper Contributor)
Solution

Hi @Jay L  the JSON code for formatting the image column is:

{
"elmType": "img",
"style": {
"width": "100px"
},
"attributes": {
"src": "@currentField"
}
}

 

imageColumn.png

 

If you want to make it clickable then the JSON is:

{
"elmType": "a",
"attributes": {
"href": "@currentField",
"target": "_blank"
},
"children": [
{
"elmType": "img",
"style": {
"width": "150px"
},
"attributes": {
"src": "@currentField"
}
}
]
}

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User

View solution in original post