Sunday, 8 July 2018

Trumbowyg: Django server can detect file upload but not image URL input

I'm using Trumbowyg, a WYSIWYG JavaScript editor which has a feature of rendering images from URLs pasted in. It also has an upload plugin which enables uploading local images and custom server side handling.

My python/django function upload_image() can successfully detect the uploaded image - however when I use the URL image input, my python function cannot detect it. Trumbowyg simply renders the image without going through my python backend.

Here's my code:

.js

$('#id_content').trumbowyg({
    btnsDef: {
        // Create a new dropdown
        image: {
            dropdown: ['insertImage', 'upload'],
            ico: 'insertImage'
        }
    },
    // Redefine the button pane
    btns: [
        ['strong', 'em', 'del'],
        ['link'],
        ['image'], // Our fresh created dropdown
    ],
    plugins: {
        // Add imagur parameters to upload plugin for demo purposes
        upload: {
            serverPath: '/upload_image/',
            fileFieldName: 'content_image',
            urlPropertyName: 'url'
        }
    }
});

.py

def upload_image(request):
    print('Success') #only prints when I use the upload input, not the URL input

Why can in detect the uploaded image but not the URL input?



from Trumbowyg: Django server can detect file upload but not image URL input

No comments:

Post a Comment