We have a SharePoint BCS Profile page (with XSLT customization). In this page we have to load an image in one of the column/cell. There is no problem in loading the image with the IMG tag until the image is not available. If the image is not available in the given URL, it will normally show the cross mark (X) symbol.
The customer requirement is below:
If the image is not available in the given URL location then show an alternative image / text (Preview not Available).
By adding the below tag you can overcome this issue
<img src=”<Image URL>” alt=”” onError=”this.src=<Alternate Image URL>’/>
We have to be very cautious when we use this code. The browser will be stuck in an endless loop if the onError alternate image itself gives an error in loading. So to avoid this use the below code
<img src=”<Image URL>” alt=”” onError=”this.onerror=null;this.src=<Alternate Image URL>’/>