Crop and Upload Profile Photos with Livewire

06. Cropping and dispatching

View full source code

Using Livewire, Alpine and Cropper.js (or any cropping library), we’ll create an embeddable form field for users (or any other model) to upload profile photos.

The form element will launch a modal, where users can crop and adjust their profile photo, before being able to preview and save the cropped image — or clear everything out and start again.

You’ll learn:

  • How to launch modals in Livewire
  • How to use Cropper.js with Alpine
  • How to resize images on the backend with the spatie/image package
  • How to pass data between Livewire components
Want to stay in the loop about new content?
Of course you do.

© 2024 Codecourse Ltd. All Rights Reserved. Born in the UK.