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

feat: add support for uploading images via blazor method or controller. #17

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dandeto
Copy link
Contributor

@dandeto dandeto commented Sep 2, 2024

This may resolve #10, but this might not be exactly what you had in mind. Regardless, I added the ability to upload images via a Blazor method, or a controller action. After uploading, the images get inserted as an img tag with the src attribute set to the path of the uploaded image. This is something I need for my project, so I went ahead and fixed it myself. The base64 encoding behavior continues to be enabled by default - this server-side uploading feature must be configured by the user.

In the MudHtmlEditor.razor.cs file, I added three new parameters and one new method. Also, I added a settings object to group the existing placeholder setting with the new ones I added before they get passed via interop to the JS side of the component.

In MudHtmlEditor.razor.js, I added uploadImageHandler - a custom handler for the (unfortunately undocumented) quill uploader module - and a supporting upload function which does the actual upload to the server.

In the remaining files, I prepared an example controller method and Blazor method that will upload the image to the wwwroot/images folder on the server, and return a url like images/image.png as the response for the JS to pick back up so it can insert that url as part of the resulting img tag.

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

Successfully merging this pull request may close these issues.

add support for custom handling of image uploads
1 participant