Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Show default image when image not found

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 956
    Comment on it

    When we show a profile image we get image path from database and show that image as a profile image. But if image not found or image path is not correct then we see a broken image. So we add a conditions there to show a defualt image. But if we use onError event there is no need to add a conditions script. onError event will fire when image not found or image format is not correct. For example

    There was an error in img tag when no image source found. I used this

    <  img  src="path/myimage.png" onerror="this.src='path/defualtImage.png'" />
    

    and it works fine for me. Try it

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: