Release
tbtop/admin 0.9.1: crop images before upload
Crop an image in the browser before it uploads, with a fixed aspect, a choice of aspects or a round avatar mask. Plus @inertiajs/react as a peer dependency, the one breaking change, and fixes for forms and selects.
0.9.1 opens the 0.9 line (0.9.0 is never published). An upload field can now crop an image in the browser before it uploads, and @tbtop/inertia-admin takes @inertiajs/react from your app instead of bringing its own copy. That is the one breaking change, and most apps need no step for it. The rest are fixes to forms, selects and the command palette.
Crop before upload
crop() puts a crop dialog between picking an image and uploading it. The browser cuts out the selection and uploads only the result, so convertTo() and quality() apply to the cropped image.
$s->upload('cover')->accept('image/*')->crop('16:9')->convertTo('webp'),
$s->upload('avatar')->accept('image/*')->crop('1:1')->cropCircle(),
$s->upload('photo')->accept('image/*')->crop(), // free selection
$s->upload('hero')->accept('image/*')->cropAspects(['16:9', '4:3', 'free']),- An aspect is
W:Horfree.cropAspects()lets the editor switch between several, andcropCircle()draws a round mask for avatars while the stored file stays rectangular. - With
multiple()the dialog opens for each image in turn. Cancelling one skips that file only. - Only JPEG, PNG and WebP open the dialog, and they keep their type. SVG, GIF, HEIC, AVIF and other files upload unchanged.
- The aspect guides the editor and is not validation: add Laravel's
dimensions:ratio=rule to enforce it. The original is not stored, so there is no re-crop later. - The PHP and Node packages have the same three methods. The crop library loads only when a dialog first opens.
Inertia comes from your app
@tbtop/inertia-admin now lists @inertiajs/react 3 as a peer dependency, next to react and react-dom. The admin uses the router your app already boots, so a second copy of Inertia can no longer leave the admin's links calling a router that was never initialised. An Inertia React app already lists the package and needs no change; with Yarn or an older npm or pnpm, run npm install @inertiajs/react (or yarn add) if it is missing. The PHP package and @tbtop/admin on Node are unaffected.
Fixes
- Enter in a select's search box no longer submits the form, and a failed async search no longer shows an endless skeleton.
- Enter activates the focused result in the command palette.
- A rich text field follows form updates and resets, and edits typed while a submit is pending are kept.
- A datetime field clears on form reset, and a cleared media field stays empty while its id is still loading.
- Deleted notifications no longer come back after a stale refresh.
- Node: the
presentrule fails when the key is missing, and table export trims its search query like the table does.
Upgrade
Move tbtop/admin, @tbtop/inertia-admin and, on Node, @tbtop/admin to 0.9.1 together. A Composer constraint of ^0.8 will not pick up 0.9, so change it to ^0.9. The one step is in Upgrade to 0.9, and cropping is in the fields docs. Every change is in the changelog.