Why would the supplied alt text not display when an image fails to load?

耗尽温柔 提交于 2019-12-12 02:33:23

问题


I attempted to add update 10 to this post: Why does my img error function fail?, but I would have surpassed the maximum post length, and so have to start a new question.

The "obvious" issue I've been forgetting this whole time is that I'm supplying an "alt" text value for each image and so, whenever they aren't loaded or don't display for any reason, the alt text should display in place of the image, right? And it's not - ever. So, since this is not happening, nor did any of the answers work, maybe for some reason my site doesn't realize when the images are "bad"... is that possible?


回答1:


There is another likely explanation.

Often other servers will provide a different image rather than the desired image when you try to load their image onto your web page on your own server. This way there is an image there, so no error is detected. But you still don't see the image that you wanted to see.

This is definitely a possible explanation of why the plug-in that I suggested (and someone else later) would not work. The plug-in cannot tell what the image was supposed to have been, so it is unable to detect whether the image you wanted to see is there, or just a blank image provided by the server instead as a way of blocking you from using their images at your site.

You can find out for yourself whether this explanation is applicable for any of the images which mysteriously don't seem to be detected as having an "error" and yet do not show up.

Simply right-click on the image and use the options your browser provides to inspect the image / examine its URL or other properties. If there is an image there but yet no image shows, then the server is replacing the real image dynamically with an empty image when you try to cross-link to it and load their image within your site.




回答2:


To try to answer why alt text is not displayed...

Some browsers use alt to display in place of a broken image while others use the title. See: Why doesn't alt text show up in image

You can also read about the difference between alt and title attributes here: alt and title tag differences



来源:https://stackoverflow.com/questions/17956938/why-would-the-supplied-alt-text-not-display-when-an-image-fails-to-load

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!