Skip to content

LWC Image Cropper for Salesforce that allows users to crop & upload an image.

License

Notifications You must be signed in to change notification settings

Filosek/lwc-image-cropper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 

Repository files navigation

LWC Image Cropper

This component is a LWC adaptation of Croppr.js made by James Ooi with simple file upload functionality. Croppr.js version used here is modified (fixed condition racing when using larger images) and available as a forked repo here

ImageCropperDemo

Custom Labels

Custom Labels used in component: ImageCropperBrokenFileAltText - Showed when uploaded file is broken

image

ImageCropperButtonLabel - Label showed on button that is capable of croping and uploading an image

image

ImageCropperErrorTitle - Title of error toast

image

ImageCropperLabel - Label displayed over upload button

image

ImageCropperSuccessTitle - Toast title when upload succeeded

image

ImageCropperUploadSuccessMessage - Toast message when upload succeeded

image

Record Page properties

Configurable properties for Record Page Builder:

  • Aspect ratio - Constrain the crop region to an aspect ratio.
  • Max crop width - Constrain the crop region maximum width to provided value (px).
  • Max crop height - Constrain the crop region maximum height to provided value (px).
  • Min crop width - Constrain the crop region minimum width to provided value (px).
  • Min crop height - Constrain the crop region minimum height to provided value (px).

Experience Builder properties

Configurable properties for Experience Builder:

  • Record Id - Defaults to {!recordId} to provide record Id from experience site context.
  • Aspect ratio - Constrain the crop region to an aspect ratio.
  • Max crop width - Constrain the crop region maximum width to provided value (px).
  • Max crop height - Constrain the crop region maximum height to provided value (px).
  • Min crop width - Constrain the crop region minimum width to provided value (px).
  • Min crop height - Constrain the crop region minimum height to provided value (px).  

 

Copyright © 2022 Filip Osiński. Released under the MIT License.