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
Dennis Koch
Dennis Kochβ€’2y ago
The editor is quite limited. Not sure whether that is possible. You could extract image URLs on save and then validate them.
Messenger of truth
Messenger of truthOPβ€’2y ago
Can you explain more about "extract image URLs on save and then validate them" ?
Dennis Koch
Dennis Kochβ€’2y ago
Use the validation hook, get the string data from the editor and then use a regex or similar to get the image urls.
Messenger of truth
Messenger of truthOPβ€’2y ago
As you say, image was uploaded on the server ?
Dennis Koch
Dennis Kochβ€’2y ago
Yes. You can probably only do this in a hacky way, when you already try to save. Not 100% sure though.
Messenger of truth
Messenger of truthOPβ€’2y ago
So besides richEditor, can I use any other software to support this? How about tinyMce or CKEditor ?
Messenger of truth
Messenger of truthOPβ€’2y ago
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.
Dennis Koch
Dennis Kochβ€’2y ago
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()
Messenger of truth
Messenger of truthOPβ€’2y ago
Thank you, are you a co-founder of filament πŸ˜„
Dennis Koch
Dennis Kochβ€’2y ago
Maybe you could also extend RichEditor and overwrite handleFileAttachmentUpload I haven't tried this myself.
Messenger of truth
Messenger of truthOPβ€’2y ago
I will try
Dennis Koch
Dennis Kochβ€’2y ago
A maintainer – not co founder πŸ˜… Mainly helping here on Discord
Messenger of truth
Messenger of truthOPβ€’2y ago
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? πŸ˜„
Dennis Koch
Dennis Kochβ€’2y ago
You heard right πŸ˜…
Messenger of truth
Messenger of truthOPβ€’2y ago
I wish I could try it in the future. Thank you again πŸ˜„
Messenger of truth
Messenger of truthOPβ€’2y ago
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.
Want results from more Discord servers?
Add your server