Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show default image if image not found in HTML 5 [duplicate]

Tags:

html

image

I want to show default image describing that image not found when one of the images in page is not found .

How to do it ?

like image 732
RASKOLNIKOV Avatar asked Dec 25 '22 19:12

RASKOLNIKOV


1 Answers

Think that you want to show in body default.jpg but this image not exist in application or in server.You want to show meaningful image to user describing that image not found.You want to show ImageNotFound.jpg to user

This is a solution:

<img src="default.jpg" onerror="this.src='ImageNotFound.jpg'" />
like image 58
RASKOLNIKOV Avatar answered Jan 04 '23 22:01

RASKOLNIKOV