I get a profile image from Twitter and store the image url in my database. some url gives broken image where the url ends with image extension and can anyone help me to check the image is a valid image or broken image. if broken image exists, i need to display a default image..
var image = opinionmakers[i].user_image;
if (type == 'Twitter' && image.match(/jpeg/)) {
img = image.slice(0, -12) + ".jpeg";
} else if (type == 'Twitter' && image.match(/jpg/)) {
img = image.slice(0, -11) + ".jpg";
} else if (type == 'Twitter' && image.match(/JPG/)) {
img = image.slice(0, -11) + ".JPG";
} else if (type == 'Twitter' && image.match(/png/)) {
img = image.slice(0, -11) + ".png";
} else if (type == 'Twitter' && image.match(/gif/)) {
img = image.slice(0, -11) + ".gif";
} else {
img = image;
}