Skip to content

Take User Profile Picture ​

A simple component that makes use of the Media Capture and Streams API to allow Salesforce users to take a new photo with their device's camera and use it to update their personal user profile.

Type: Component

Available in: App Page · Home Page · Record Page · Flow Screen

Read on Medium ​

Allow your Salesforce Users to take a new Profile Picture

Allow your Salesforce Users to take a new Profile Picture

Attributes ​

NameTypeDefaultDescription
default-camerastring'front'The camera to start with, front or back. Devices with only one camera use that one.

Usage ​

html
<c-take-user-profile-picture default-camera="front"></c-take-user-profile-picture>

The component is self-contained: it asks for camera access, takes a photo and updates the profile picture of the current user. To use the camera for something else, see Camera Capture.

Custom Labels ​

The texts users see are Custom Labels, so they can be translated in Setup with the Translation Workbench. Copy them together with the component.

NameValue
CameraCapture_CapturePhotoCapture Photo
CameraCapture_ErrorError
CameraCapture_ErrorAccessingCameraError accessing camera
CameraCapture_NotSupportedgetUserMedia is not supported in this browser
CameraCapture_StartCameraStart Camera
CameraCapture_StopCameraStop Camera
ErrorUtils_UnknownErrorUnknown error
TakeUserProfilePicture_CapturePhotoCapture Photo
TakeUserProfilePicture_ErrorSavingError saving the profile picture
TakeUserProfilePicture_NewProfilePreviewPreview of the new profile
TakeUserProfilePicture_StartCameraStart Camera
TakeUserProfilePicture_StopCameraStop Camera
TakeUserProfilePicture_SuccessSuccess
TakeUserProfilePicture_TitleTake User Profile Picture
TakeUserProfilePicture_UpdatedProfile picture has been updated, it takes some time until the change is visible
TakeUserProfilePicture_UpdateProfileUpdate Profile Picture

Component Dependencies ​

NameTypeDescription
UserProfilePictureControllerApexController class for updating the user's profile picture.
UserProfilePictureControllerTestApexTest class for UserProfilePictureController.
errorUtilsLWCShared functions to read error messages and show error toasts.
cameraCaptureLWCBuilding block for the live camera view and taking photos.

Released under the MIT License. · llms.txt for AI agents