• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Placeholder for broken images


Active member

I hate to see posts with broken images, so I end up using a simple jquery script that I found in stackoverflow to replace the error image with a placeholder:

So, before </body> add:

jQuery("img.bbCodeImage").one('error', function () {
    jQuery(this).attr("src", "/styles/default/xenforo/placeholder.jpg");
}).each(function () {
    if (this.complete && !this.naturalHeight && !this.naturalWidth) {
Don't forget to upload the placeholder image to your server!

I placed this in the suggestion forum so this can be added to the default theme and because I don't have privileges to posts this in the tips section :)