I want to create a custom field for my Laravel Nova application. Thanks to Laracast I already figured out how I can to this (here). But I don't know how to edit the create, update and delete method and sadly I also haven't found anything about it on google...
The reason why I need to edit those functions is because I am using spatie/media-library to take care about my images I upload. Now I want to add a textfield editor to my Laravel Nova Recourse which can also handle images. However, those images should be added to the spatie/media-library and when updating or deleting the recourse, the image should of course also be deleted...
I have implemented such kind of function in my front end already with the quill editor. Users have the possibility to create comments and upload images as well within the comments. The images are send as base64 strings within my text field to my controller which then is taking care about saving the base64 image to my spatie/media-library.
Any idea how I can do the same with Laravel Nova?
Kind regards and thanks!
Try this package to implement media library in Laravel Nova
https://github.com/ebess/advanced-nova-media-library
Related
I'm trying to create a front-end AJAX file uploader for a form and everything is working perfect, except for one issue.
I used deferred binding to enable uploading before the record is created in DB.
In a rare scenario, when someone uploads a file and doesn't send the form the record is not created, but the attached file still exists.
I don't know if there is a build-in solution for this problem is October CMS.
A better example is RainLab Blog Plugin. If you try a new post and add a featured image but not save the post and close the tab, the post doesn't create but the file remains in storage/app/uploads/public.
I was thinking of writing an scheduled task to delete unbinded files, but don't know how to detect them.
Does anyone have a solution for this issue?
you can look at the table:
system_files
and the ones without a
attachment_id or/and
attachment_type or/and
field
are unused maybe the media table should be cleaned too.
I want to use Dropzone.js, but all tutorial I've found are exclusive upload forms.
I have found no doc with mixing image upload with user creation for example.
Am I in a wrong use case?
If not, how can I do it, I don't know how to pass uploaded file name?
How should I have a dedicated form to upload pic, and relation with my User creation in other form...
I'm really not sure how to do this!
Any idea would be appreciated!!!
It seems that Sonata Media has only two strategies when it comes to cropping/resizing the uploaded image, Sonata\MediaBundle\Resizer\SimpleResizer and Sonata\MediaBundle\Resizer\SquareResizer. Both these strategies are automatic, meaning that the users don't have a say in how they want the image to be resized/croppped.
I would like to give the user an option to select the portion of the image that is more relevant, kind like the jQuery Image Cropper library used by GenemuFormBundle, but I don't even know where to start. Will I need to create my own Admin class instead of using Sonata\MediaBundle\Admin\BaseMediaAdmin? Has anyone write a bundle that I can use? How do you manage your galleries usually?
You should look at ComurImageBundle. It's far easier than Sonata Media, doesn't create anything in database and lets you upload with jquery file uploader, crop with jcrop and other useful things.
I wrote a simple admin extension that give you the ability to customize the images by format. It's actually a Work In Progress that needs some test, documentation and refactoring, but it does the job, it's lightweight and it's shipped with a resizer to handle fixed dimensions.
You can find it here: https://github.com/julien-maitan/sonata-media-crop
If you are using sonata media bundle with sonata admin, there is a picasa photo editor already in place in media edit form.
Please check.
Well this is the only problem that bugs me a lot every time I create a CMS.
Say I have included the functionality to add some images with text (Not a image gallery) . This is the create function of CRUD. The read and delete are also not very difficult. The only problem I face is with the update function.
How should the image update be handled. How can I know that if the user wants to change the image and later if he submits a new image.
If he checks to change the image and uses the same image to upload, it would be useless to first unlink the previous image and upload the same image again.
How are these kind of things handled?
At this moment I am using codeigniter for Development.
Most CMS's will have image functionality baked in. I'd first suggest not trying to reinvent the wheel here.
In ExpressionEngine for example (on a codeigniter backend) you're givin a 'field tag' <img src="{{channel.img}}" />
The CMS is smart enough on the backend to change that field's value on update without you having to manually do anything. The only issue is if it overwrites the image name/location rather than created a new image in the uploads and leaving the previous one in there.
This is how it's handled in Umbraco CMS as well.
What else do you need?
I've got the PyroStreams module for PyroCMS and made a stream called portfolio. Everything is working as expected, however it only allows to upload just one image for my file field. That is obvious, but I'd like to know if there's a way to upload multiple images for one stream entry without adding x number of extra file fields. Or do I need to code an extra field type myself to support this? Maybe someone's got it already?
Thanks
According to me you have to create a separate database table that will hold all the images those are related to particular portfolio and the portfolio id by id by which you can fetch the images for particular record and then use any multiple image upload library like http://www.plupload.com/example_queuewidget.php to upload multiple images in the portfolio image table. Hopefully this will help you in achieving what you want.
There's a multi-upload files field type available on the pyrostore.