Riyan Satria
Riyan Satria

Reputation: 21

There is no src attribute in my <img> after upload via custom image upload adapter

I tried to add custom image upload adapter by following official documentation on ckeditor site, copy from site and paste to my code. My image was success to uploaded. But if I get content from my editor (using editor.getData()), I get this result :

<figure><img></figure>

The img tag haven't any attribute, even src attribute. So, how to solve this? My code exact like the code in documentation (in the end section)

https://ckeditor.com/docs/ckeditor5/latest/framework/guides/deep-dive/upload-adapter.html

Upvotes: 1

Views: 937

Answers (1)

Reinmar
Reinmar

Reputation: 22023

My guess is – your server does not return the URL in the right format.

Add a console log here:

        console.log( response ); // ADDED

        // If the upload is successful, resolve the upload promise with an object containing
        // at least the "default" URL, pointing to the image on the server.
        // This URL will be used to display the image in the content. Learn more in the
        // UploadAdapter#upload documentation.
        resolve( {
            default: response.url
        } );

You should see on the console an object with a property url. If that's not true, then you have to fix your server implementation.

Upvotes: 2

Related Questions