Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: can i pass in base64 encoded data #109

Closed
rabol opened this issue Nov 13, 2023 · 1 comment
Closed

Question: can i pass in base64 encoded data #109

rabol opened this issue Nov 13, 2023 · 1 comment

Comments

@rabol
Copy link

rabol commented Nov 13, 2023

Hi

I have images saved as base64 encoded data in the db, is that supported by this field ?

@ctessier
Copy link
Owner

Hi @rabol, thank you for your message.

The Laravel Nova image field type doesn't support base64 out of the box.
However, you should be able to make use of your base64 data using Laravel Nova native methods such as resolveUsing: https://nova.laravel.com/docs/resources/fields.html#field-resolution-formatting
That would involve taking the base64 as the input, create a temporary binary file and return the file path so the image can be displayed.

Then, when saving a file, you can use fillUsing to take the file path as an input, and generate the base64 string to hydrate the model: https://nova.laravel.com/docs/resources/fields.html#field-hydration.
As an alternative when saving, you can try to call ->convert('data-url'), and see what it does... This is provided by Intervention Image and made available by this package. I have never tried it though.

Hoping this help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants