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

img src attribute is set to [object Object] #95

Open
bastienguillon opened this issue Dec 24, 2020 · 2 comments
Open

img src attribute is set to [object Object] #95

bastienguillon opened this issue Dec 24, 2020 · 2 comments

Comments

@bastienguillon
Copy link

I have found a weird behavior when converting images insert ops : the src attribute of the output img tag is always set to [object Object]

Here is a commit with a unit test which reproduces the issue: bastienguillon@3ee6fdb

Input:

const delta = {
    ops: [
        {
            insert: {
                image: {
                    alt: null,
                    url: "https://i.imgur.com/XSoFJ8l.gif"
                }
            }
        }
    ]
};

const output = new QuillDeltaToHtmlConverter(delta.ops, { urlSanitizer: url => url }).convert();

Expected output

<p><img class="ql-image" src="https://i.imgur.com/XSoFJ8l.gif"/></p>

Actual output

<p><img class="ql-image" src="[object Object]"/></p>
@bastienguillon
Copy link
Author

I wrote a dirty hack to temporarily fix the issue, but it is clearly not a viable solution

for (const op of delta.ops) {
	if (op?.insert?.image) {
		op.insert.image.toString = () => {
			return op.insert.image.url;
		};
	}
}

@volser
Copy link
Collaborator

volser commented Aug 23, 2021

in standard quill delta, image is string. It looks like you changed format

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

2 participants