In my forums i allow the user to enter the image URL in the message body but user can enter any random URL(instead of image URL), which can ask user the credentials like in this SO post Prevent HTTP Basic Authentication from displaying prompt for images .
Solution given in above post is not useful for me as i am tracking the user cookie and adding crossorigin="anonymous"
will not allow browser to send the cookie and without my website wont function.
Is there is any easy to implement solution available , also it would be possible if anybody let me know how Stackoverflow does it.