Manage Media from frontend easily? #17392
-
Hi there, I am looking to create a website made for documentation, similar to how notion.so is structured. One of the primary functions we are looking to add is to allow maintainers of the documentation to easily add images, by copy and pasting or even dragging and dropping from a different program / file. (Similar to how you can copy / drag images from your screenshots to a OneNote document. Here is an example of what I am looking for: example.mp4Now I did some research on this and came to the conclusion that we probably have to make a custom part to implement this, because from what I can tell the way the Media Library is structured it isn't really built to take in images from the frontend, at least not in this way. This seems relatively possible to do out of the top of my head but I am not the greatest when it comes to this stuff so I think I might run into some challenges and therefore will probably have to spend some time figuring this out. Therefore I was wondering if my assumption was correct and I indeed do need to create a custom part to implement this functionality and that there isn't some standard functionality that could make this work that I overlooked and therefore wasting my time. EDIT: After some brainstorming and looking through my options I concluded that this may be my best option: Any tips, advice or perspective on the above is very much welcome and appreciated. Thanks in advance for your insight! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Pasting images into editors in a way that they're saved to the Media Library as files is not supported (#6145). However, with Trumbowyg fields (the built-in HTML WYSIWYG editor), you can paste images as base64-encoded URLs (i.e. the files will be embedded into the markup, as opposed to saved as files). This is less efficient, just FYI. You can use OC's built-in MarkdownBodyPart to provide a base of the editor, and add something that'll upload pasted images (the editor plugin used is EasyMDE; check out what other people have done on this front from here: Ionaru/easy-markdown-editor#7 (comment)). When working with content items on the frontend, keep security in mind, and e.g. don't let people save custom HTML, or browse the Media Library with a Media Field. See https://docs.orchardcore.net/en/latest/reference/modules/Markdown/#sanitization. Tips for managing content items from code, what you'll need: https://github.com/Lombiq/Orchard-Training-Demo-Module/blob/dev/Lombiq.TrainingDemo/Controllers/PersonListController.cs. |
Beta Was this translation helpful? Give feedback.
Pasting images into editors in a way that they're saved to the Media Library as files is not supported (#6145). However, with Trumbowyg fields (the built-in HTML WYSIWYG editor), you can paste images as base64-encoded URLs (i.e. the files will be embedded into the markup, as opposed to saved as files). This is less efficient, just FYI.
You can use OC's built-in MarkdownBodyPart to provide a base of the editor, and add something that'll upload pasted images (the editor plugin used is EasyMDE; check out what other people have done on this front from here: Ionaru/easy-markdown-editor#7 (comment)).
When working with content items on the frontend, keep security in mind, and e.g. don't let peop…