Detect HTTP status code when linking to external images
My rails app contai开发者_StackOverflowns something like the following in a view template
<%= image_tag 'http://foo.com/images/1' %>
Sometimes, if the url does not contain an image, the hosting site will return a response with a 404 or 302 status.
In this case, the alt-text for the image is displayed.
How can I detect the HTTP response status in order to insert a different image? (such as the next image, or a default 'not found' image)?
Adding :onError => "alert('error')" To the image tag triggers when the image doesn't load.
精彩评论