My requirement is as follows (please note both the things I have to do programmatically) 1. To upload a profile photo for an user 2. And then make the image available for user/other users to view on that user's profile page.
For the first requirement, my approach was to create an Attachment with parent-Id as the User's ID for whom a picture attachment have been created.
But unfortunately, User record can't have an attachment. However, User have contact object reference and contact can have an attachment. (this I did to achieve feature one). Limitation for this approach is, I have to create a Contact and Account object.
Now to show the image on user's profile, I created a custom formula field (in User object) which uses the uploaded attachment's id [can be reached through contact reference present in User object] to show the image on User's profile.
This question is to just validate the approach or if there is any better approach for Photo upload for user.