Users can upload an image for their avatar, or specify a URL from another website.
This is stored in a 'user.image' column in a database.
User uploads image - A randomly generated 10 letter filename with the original extension is saved locally, and the filename is saved to the database (not the entire path)
User specifies URL - The entire URL is saved to the database
However, when going to display the image, how am I to know whether it was an uploaded image (e.g. filename only in column), or if the user specified a full URL?
Possible thoughts are:
- Checking to see if 'user.image' begins with the string 'http://' - but could be expensive performance wise under high traffic
- Physically downloading the specified URL at the time of saving, and saving that image to the local server, and then updating the database with only the filename (not the path, since its local now)
Or is there a better way?