Skip to content
This repository has been archived by the owner on Mar 8, 2019. It is now read-only.

Image with src in format "data:image/...." is removed #334

Closed
Andreyco opened this issue Feb 17, 2013 · 1 comment
Closed

Image with src in format "data:image/...." is removed #334

Andreyco opened this issue Feb 17, 2013 · 1 comment

Comments

@Andreyco
Copy link

Writing client side image upload plugin. So far so good, everything works perfectly.
Tried to insert image with data source & URL source as well, using built-in command (pretty easy, thanks!)

// 1st method
composer.commands.exec("insertImage", { src: "data:image/jpeg;base64,/9j/4AAQS...", alt: "" });
// 2nd method
composer.commands.exec("insertImage", { src: "http://....", alt: "" });

Using any of these methods, image is inserted and visible in Composer, great!

The problem
Then it comes to original form/textarea submit process.
If I use 1st of these methods, inserted image is not present - other content is present (as HTML, ofc)
Edit
Plus, change:composer event is not fired after image is added to composer, but is fired, after image is deleted from composer! This bug is present in Google Chrome only.

So I think, this has something with parser. Is there a way to write custom parser rule, that do not require touching original library? Something like writing new command, which is pretty easy!

wysihtml5.commands.insertImageAdvanced = {
        exec: function(composer, command, value) {
                    ....
                },
                ....
}

If there is no way, how to add custom parser method, Imho, modifying"src" method that checks src attribute to accept data URL would do the job. But this is up to original authors of wysihtml5

@Andreyco
Copy link
Author

so I just added a line to original src method to allow data:image/(jpeg/png/gif),base64 input...
Solved here

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant