I am trying to predetermine is a given url is a valid image or not. In JS, it would be ideally look like
if (isValidImg(url)){
...add image DOM
} else { ... discard...}
Given img.src is happening asynchronously, how can I synchronously know if the url is a valid image?
Valid meaning exist, and has a image related format or mime type.
"http://google.com/fake.img" is not valid
"http://cdn.sstatic.net/stackoverflow/img/sprites.svg?v=a7723f5f7e59" is valid