Images
Uploads
Set the disk
By default, Canvas will attempt to use the disk defined in nova.storage-disk
config.
You can override this using the ->disk(...)
method:
You can also pass a path as the optional second parameter:
Optimisation
Canvas uses Spatie image optimizer to automatically optimise uploaded images, which is essential for performance on your applications front-end.
Configure image optimisation
Publish the config file:
php artisan vendor:publish --provider="Spatie\LaravelImageOptimizer\ImageOptimizerServiceProvider"Update
config/image-optimizer.php
Using your own endpoint
The built-in endpoint should work fine for most use-cases, but its completely replaceable if you want to add additional functionality.
You can simply change the endpoint path in the nova-canvas.images_endpoint
config.
Your endpoint should accept a POST request with the following:
$_FILE (
image
) - The image to upload.$_POST (
disk
) - The disk to upload images to.$_POST (
path
) - The path to upload images to.
If the upload is successful it should respond with 200 OK
and a public path to the uploaded image as JSON:
If something goes wrong it should respond with 422 Unprocessable Content
or 500 Internal Server Error
, you can also provide an error message as JSON: