This will introduce a bug if you name something, say, "http://joke.com/not-a-jpg". Campfire does this, actually. You could check for ".png", ".gif", and ".jpg".