Guide section
Basic img onerror pattern
Clear the error handler before changing the source. That prevents an infinite fallback loop if the fallback URL ever fails.
<img
src="/photo.jpg"
width="600"
height="400"
alt="Product image"
onerror="this.onerror=null;this.src='https://fallback.pics/api/v1/600x400?text=Image+Unavailable'"
/> Guide section
Choose fallback copy by context
Use Product image for catalog cards, Avatar for profile photos, Image unavailable for failed CMS media, and a skeleton placeholder only for temporary loading states.
Guide section
Keep alt text meaningful
The fallback URL is a visual replacement. Your alt text should still describe the content the image represents.