I have a website I am working on that uses lightbox2 and a set of links that may or may not link to an image on the server. For display purposes I use some javascript that will replace images that do not exist. This is that code:
function imgError(image) {
image.onerror = "";
image.src = "/images/noimage.jpg";
return true;
}
However, when using lightbox2, it will still try and display the image instead of a replacement, leaving lightbox2 stuck in a loop trying to load an image that isn't found. These are the full lines of code I am using currently:
<div class="more-images">
<a href="img/12/GD/clock-b.jpg" data-lightbox="main" data-title="{$inf[1]}"><img src="img/12/GD/tb/clock-b.jpg" class="image-bar" onerror="this.onerror=null; this.remove();"></a>
<a href="img/12/GD/clock-cover.jpg" data-lightbox="main" data-title="{$inf[1]}"><img src="img/12/GD/tb/clock-cover.jpg" class="image-bar" onerror="this.onerror=null; this.remove();"></a>
<a href="img/12/GD/clock-back.jpg" data-lightbox="main" data-title="{$inf[1]}"><img src="img/12/GD/tb/clock-back.jpg" class="image-bar" onerror="this.onerror=null; this.remove();"></a>
<a href="img/12/GD/clock-insert.jpg" data-lightbox="main" data-title="{$inf[1]}"><img src="img/12/GD/tb/clock-insert.jpg" class="image-bar" onerror="this.onerror=null; this.remove();"></a>
</div>
How would I get lightbox2 to display a placeholder image when one can't be found on the server? Thanks!