Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addImageBlobHook displays both base64 and server uploaded image #1624

Closed
ct1735x opened this issue Jul 1, 2021 · 3 comments
Closed

addImageBlobHook displays both base64 and server uploaded image #1624

ct1735x opened this issue Jul 1, 2021 · 3 comments
Labels
Milestone

Comments

@ct1735x
Copy link

ct1735x commented Jul 1, 2021

I use addImageBlobHook to upload images to my webserver and render it in the editor. this works fine.
However, the base64 image is still rendered in the editor, I don't want to.

Screenshots :
https://i.postimg.cc/K3vQrmFx/aaa.png
https://i.postimg.cc/3wCF3v8H/bbbb.png

You can see that the image is displayed twice in the editor; And the html code shows bot the base64 image and the link to the uploaded image

#127 is not fixing this issue.

Here is my code snippet :

hooks: {
addImageBlobHook: function (blob, callback) {

        let image = new FormData();

        image.append(0, blob, blob.name);

        fetch('upload.php', {
            method: 'POST',
            body: image
        }).then(function (response) {
            if (response.ok) {
                response.json().then((value) => { 
                    if (value === 0) { 
                        alert("file upload error");
                    } else { 
                        callback(value, 'uploaded image'); 
                    }
                });
            } else { 
                alert("file upload error");
            }
        })
        return false; // I tried with true, and without return at all, same result
    }
}
@ct1735x ct1735x added the Bug label Jul 1, 2021
@js87zz
Copy link
Contributor

js87zz commented Jul 1, 2021

@2KLM
The duplication of uploading the image is our bug.
lt will be fixed in #1623. I'll let you know when it's released!

@ct1735x
Copy link
Author

ct1735x commented Jul 1, 2021

Removing the default hook and adding it again is a fix.

editor.removeHook('addImageBlobHook'); // remove the default hook
editor.addHook('addImageBlobHook', (blob, callback) => { ... });

@js87zz js87zz added this to the v3.0.1 milestone Jul 1, 2021
@ct1735x ct1735x closed this as completed Jul 6, 2021
@js87zz
Copy link
Contributor

js87zz commented Jul 7, 2021

@2KLM
The bug has been fixed and released in v3.0.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants