SharePoint Fallback-Bilder - ein unerwarteter Shortcut
Ich wollte in einer Spalte Logos statt Lieferantennamen – aber pragmatisch:
Lieferantenname = Dateiname → Bild wird geladen
Funktioniert gut.
Bis kein Logo existiert → Broken Image.
Mapping bauen? Wollte ich vermeiden.
Bei der Spalte handelt es sich um ein Managed Metadata Field.
Icons liegen hier:
/SiteAssets/Logos/
Das JSON für die Listview
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"style": {
"display": "flex",
"flex-direction": "column",
"align-items": "center",
"justify-content": "center",
"padding": "2px 0"
},
"children": [
{
"elmType": "img",
"attributes": {
"src": "=@currentWeb + '/SiteAssets/Logos/' + if(@currentField.label, @currentField.label, @currentField) + '.png'",
"alt": "=if(@currentField.label, @currentField.label, @currentField)",
"title": "=if(@currentField.label, @currentField.label, @currentField)"
},
"style": {
"width": "65px",
"height": "65px",
"object-fit": "contain",
"cursor": "pointer"
},
"customRowAction": {
"action": "editProps"
}
},
{
"elmType": "span",
"txtContent": "=if(@currentField.label, @currentField.label, @currentField)",
"style": {
"margin-top": "2px",
"font-size": "9px",
"line-height": "1.0",
"text-align": "center",
"color": "#555555",
"max-width": "120px",
"overflow": "hidden",
"text-overflow": "ellipsis",
"white-space": "nowrap",
"cursor": "pointer"
},
"customRowAction": {
"action": "editProps"
}
}
]
}
Der eigentliche Trick
Ein transparentes 1x1 PNG genommen, Namen entfernt → Datei heißt einfach:
.png
Upload in SharePoint funktioniert.
Wenn kein Logo gefunden wird:
/SiteAssets/Logos/.png
Ergebnis:
- kein Broken Image
Kein schöner Ansatz. Aber effektiv.

Kommentare