Drupal 8 natively allows to insert images within a body field, of course if the format text used allows this functionality. But can we do the same and easily insert documents, attachments, within a body text ? We have many solutions with Drupal 8 to associate documents with content. From a dedicated field, allowing us to master its location on the rendered page, from paragraphs allowing the author to position his document wherever he likes, while maintaining mastery of the final rendering, or with the Media entity suite that also allows us to integrate media, including documents, into a body with the module entity embed. In short, there are many solutions.
We also have a very simple solution, configurable in one minute top chrono, to be able to upload a document into a body with the module D8 editor file upload. Let's quickly discover this module.
After installing the module, we will configure the text format, with CKEditor, we will use with the body field.
Configure the full HTML text format and click the corresponding button.
You notice a new button (a paper clip) in the list of available buttons to activate the upload file widget. We drag and drop this button into the active toolbar.
We dropped this new button in the active toolbar (next to the Image button). This action displays the plugin settings that allow us to specify the file transfer directory, the allowed file extensions, and the maximum size of a file.
If you have enabled the Limit allowed HTML tags and correct faulty HTML in this text format, make sure that the <a> tag has the possible attributes of data-entity-type and data-entity-uuid, as shown below.
And it's done. In less than a minute we have just configured the module and we can now upload as many documents as needed into our body text.
We can now upload a document into any body field that will use the full HTML format.
It is possible to rename the file to give it a more attractive name than the default file name.
And your content rendered with its attachment.
The formatting capabilities of files associated with a content are limited. But it is not the vocation of this module that allows to simply upload a file, in the same way as the images, into a text long field type. For an equally simple rendering. For more advanced requirements for formatting the associated documents, or the needs related to control access to these documents, you will have to recourse to other solutions.
An effective, simple module that responds to an immediate and often vital need. Sometimes it is this kind of small details that can make a big difference in the choice in a tool, and meets the basic functions that any publisher expects to have out of the box. No ?