How to display default image if image not found?

Most raising issue with html website. When you insert images into a page that can not be viewed because there is no original image. If the picture does not show, then the look of your site deteriorates. So it is very important that you fix it. Very simple way to you can fix it.

You can now set default image if there is no original image. You can use the JavaScript onerror event handler to show a default image.

<img src="SomeImage.jpg" onerror="this.onerror=null; this.src='Default.jpg'">

I think this is simplest way to solve this problem is.

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments