hxauyq
Last Updated: February 25, 2016
·
1.557K
· tiagox
Tiagox.in

Use an alt image for img HTML tags

In case you need to load an alternative image instead to show the classic alt text. You can do this:

<img src="404.png" onerror="this.src='alt.png';" />

Also, you can do anything with Javascript, in case of onerror event.

Say Thanks
Respond

5 Responses
Add your response

1003
E8144d48fd5a59d14afcc8f0ab036fa5

I cant see any code

over 1 year ago ·
1005
E3e5923c7e2954158e9b9b0493c9132c

What to do.I can't see the code

over 1 year ago ·
1081
Tiagox.in

The bug is already fixed.

over 1 year ago ·
17051
Ffebdf905fae3278a260ed03c9d165c7

This can stack overflow if the alternate image is a 404.

over 1 year ago ·
17053
Tiagox.in

@blainesch you're absolutely right. I didn't thought about that, the alternative image should exist, the idea is to set a default image that you know.

over 1 year ago ·