On Twitter, if the image is not loaded, a default image will be displayed. I checked that this is not the background image in the background-image attribute, but img## Pictures introduced with the #tag.
The question is, how does Twitter determine that the image that should be displayed failed to load?
You should check out Twitter’s developer API. There should be an introduction in it
You can use the onerror event of the img tag