Reputation: 6238
In my view I would like to load an image stored external from my server. Can happens that the image is moved in another url, then I will receive a 404.
How can I handle this in my view? For example load a local standard picture if the img return a 404?
For example with this simple HTML img tag
<img src="<%=myExternalImageUrl%>" />
Upvotes: 0
Views: 367
Reputation: 19879
I don't think you can do this in Rails, but I think you can do it with Javascript I believe. You'd need to load the image using Javascript, test the response to see if it loaded okay and then either insert it into the DOM or replace it with your default image.
Upvotes: 1