memele
4 months ago

WYSIWYG image upload

Posted 4 months ago by memele

I am creating a forum and using Trumbowyg text editor for thread and comment textareas. I want my users to be able to upload images to comments and threads using Trumbowyg's upload plugin but I am having trouble understanding the documentation (https://alex-d.github.io/Trumbowyg/demos/plugins/upload.html).

How can I allow users to add multiple images and store them in my database? I understand that I should change the serverPath to a route that would catch the image upload post request. I don't understand why the fileFieldName is set to 'image' in this example, because when I inspect it with Dev Tools the file upload input name is 'file'.

The code from Trumbowyg's documentation:

$('#editor')
.trumbowyg({
    btns: ['upload'],
    plugins: {
        // Add imagur parameters to upload plugin for demo purposes
        upload: {
            serverPath: 'https://api.imgur.com/3/image',
            fileFieldName: 'image',
            headers: {
                'Authorization': 'Client-ID xxxxxxxxxxxx'
            },
            urlPropertyName: 'data.link'
        }
    }
});

Or is there an alternative WYSIWYG editor with a simpler image upload option?

Please sign in or create an account to participate in this conversation.