monstrum/jcrop
Laravel package that integrates the JCrop jQuery image-cropping plugin, making it easy to add client-side crop selection and coordinates to PHP applications. Simplifies including JCrop assets and wiring cropping into forms.
Install via Composer (composer require <vendor>/<package>) and publish the package assets with php artisan vendor:publish --tag=jcrop-assets. Ensure jQuery is available before the plugin script. The quickest first use case is a simple image upload form with a cropping modal: include the provided Blade component or manually add the CSS/JS to your layout, then initialise JCrop on an <img> element inside a form. Check the package’s README and config/jcrop.php for default options (aspect ratio, min/max sizes, preview containers). A minimal working example: upload an image, display it in a modal, attach JCrop, and store the crop coordinates (x, y, w, h) in hidden inputs for server‑side processing.
intervention/image to perform the actual crop: Image::make($uploaded)->crop($w, $h, $x, $y)->save($path).<x-jcrop-uploader :image="$model->image" />). Pass initial crop data via props for edit forms.crop.change, crop.release) to update hidden inputs and live previews. Use the package’s restructured jQuery plugin API (standard $.fn.jcrop) for consistency.$('.jcrop-container').each(...)) and storing instance references for later method calls.tapmono/jcrop, republish assets and clear view cache (php artisan view:clear). The restructured plugin may have different file paths or option names.load event or a small delay; otherwise selection handles may misalign.X-CSRF-TOKEN in headers or use $.ajaxSetup with Laravel’s token meta tag.console.log($.fn.jcrop) to confirm the plugin is registered.$.fn.jcrop.defaults or per‑instance. The package’s config file may expose additional settings (e.g., allowSelect, bgColor); publish and edit it as needed.How can I help you explore Laravel packages today?