i'm making an admin portal where admin can create users,and when they create user they only add their basic details. so when a user logs in to the system he finds a broken image. to fix that i did some digging and found out about onerror
event in img tag. I tried using it,but it is not working.
my code : <img src="images/<?php echo $image;?>" onError="this.onerror=null;this.src='/images/abc.png';"/>
Please help me out here,this is the only task remaining to finish of my 1st project.
As mentioned, you can use PHP to check if the image exists and replace it server-side. To answer your question about the image onerror function, see: jQuery/JavaScript to replace broken images
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.