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

Unable to Dynamically Insert Images in Callback Function #4781

Open
Jarvis4555 opened this issue May 3, 2024 · 0 comments
Open

Unable to Dynamically Insert Images in Callback Function #4781

Jarvis4555 opened this issue May 3, 2024 · 0 comments

Comments

@Jarvis4555
Copy link

Description:
I'm currently working with Froala Editor and encountered an issue when trying to dynamically insert images within a callback function. Specifically, I'm unable to get the base path of Froala Editor or specify a folder location where the editor can detect SVGs or GIFs. Here's a snippet of the callback function I'm using:

callback: function (val) {
    var editor = this;
    if (val === 'v1') {
        var imageUrl = './pi_1.gif';
        if (imageUrl) {
            var html = '<table><tr><td><img src="' + imageUrl + '" alt="Image"></td></tr></table>';
            editor.html.insert(html);
        }
    } else if (val === 'v2') {
        var imageUrl = './pi_2.gif';
        if (imageUrl) {
            var html = '<table><tr><td><img src="' + imageUrl + '" alt="Image"></td></tr></table>';
            editor.html.insert(html);
        }
    }
}

Issue: As you can see in the code above, I'm specifying image URLs relative to the current file (./pi_1.gif and ./pi_2.gif). However, I would like to know if there's a recommended way to get the base path of Froala Editor or specify a folder location where the editor can detect these images.

Request: Could you please provide guidance on how to dynamically insert images in Froala Editor's callback functions? Specifically, is there a way to get the base path of the editor or specify a folder location for image detection? Alternatively, any suggestions on how to handle this scenario effectively would be greatly appreciated.

Editor version:
4.2.0

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

No branches or pull requests

1 participant