Can i validate upload image when using richEditor ?
i have a richEditor in the form, i want to validate image size when i use richEditor but i cant search in docs ?
16 Replies
The editor is quite limited. Not sure whether that is possible. You could extract image URLs on save and then validate them.
Can you explain more about "extract image URLs on save and then validate them" ?
Use the validation hook, get the string data from the editor and then use a regex or similar to get the image urls.
As you say, image was uploaded on the server ?
Yes. You can probably only do this in a hacky way, when you already try to save. Not 100% sure though.
So besides richEditor, can I use any other software to support this? How about tinyMce or CKEditor ?
GitHub
GitHub - mohamedsabil83/filament-forms-tinyeditor: A TinyMce Editor...
A TinyMce Editor component for filament. Contribute to mohamedsabil83/filament-forms-tinyeditor development by creating an account on GitHub.
I don't know. I haven't used any of them. Probably any of them could work as standalone JS, but I don't think somebody has this exact use case wired up to Filament
Maybe you could also hook into
->saveUploadedFileAttachmentsUsing()
Thank you, are you a co-founder of filament π
Maybe you could also extend RichEditor and overwrite
handleFileAttachmentUpload
I haven't tried this myself.I will try
A maintainer β not co founder π
Mainly helping here on Discord
You are amazing π
I have used filament for a week, i fallling in love with filament π
I heard that beer in Germany is very good, is it? π
You heard right π
I wish I could try it in the future. Thank you again π
I solved by used tinyMce
https://github.com/mohamedsabil83/filament-forms-tinyeditor
I publish file blade and add code
var image_size = blobInfo.blob().size / 1000;
var max_size = 500;
if (image_size > max_size) {
failure('Image is too large( '+ image_size + ') ,Maximum image size is:' + max_size + ' kB');
return;
}
in file tiny-editor.blade.php π
GitHub
GitHub - mohamedsabil83/filament-forms-tinyeditor: A TinyMce Editor...
A TinyMce Editor component for filament. Contribute to mohamedsabil83/filament-forms-tinyeditor development by creating an account on GitHub.