I've create a SharePoint list with clickable image from a link column, more info over here: SharePoint list formatting image column with clickable link from another column
Now I'm trying to fix an error, when the link column is empty it's create a faulty link instead of showing no link. I've tried the code below this but hides the image too.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "a",
"style":{
"display": "=if([$MyLinkColumn]=='','none','block'"
},
"attributes": {
"target": "_blank",
"href": "[$MyLinkColumn]"
},
"children": [
{
"elmType": "img",
"style": {
"display": "block",
"background-color": "none",
"position": "relative",
"width": "60px"
},
"attributes": {
"src": "@currentField.serverRelativeUrl"
}
}
]
}