feat: add support for uploading images via blazor method or controller.#17
Open
dandeto wants to merge 2 commits intoerinnmclaughlin:mainfrom
Open
feat: add support for uploading images via blazor method or controller.#17dandeto wants to merge 2 commits intoerinnmclaughlin:mainfrom
dandeto wants to merge 2 commits intoerinnmclaughlin:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
imgtag with thesrcattribute 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.csfile, I added three new parameters and one new method. Also, I added asettingsobject to group the existingplaceholdersetting with the new ones I added before they get passed via interop to the JS side of the component.In
MudHtmlEditor.razor.js, I addeduploadImageHandler- a custom handler for the (unfortunately undocumented) quill uploader module - and a supportinguploadfunction 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/imagesfolder on the server, and return a url likeimages/image.pngas the response for the JS to pick back up so it can insert that url as part of the resultingimgtag.