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

Insert image to trix-editor through javascript #1055

Open
adiubaidah opened this issue Apr 8, 2023 · 3 comments
Open

Insert image to trix-editor through javascript #1055

adiubaidah opened this issue Apr 8, 2023 · 3 comments

Comments

@adiubaidah
Copy link

Does anyone know how to insert attachment in trix editor with javascript ?,

  1. I have the image through the url, and that url is working properly
  2. and when i use const attachment = new Trix.Attachment({content : url}) and insertAttachment, it only display the url not the image
  • Trix version: 2.04
  • Browser name and version: Chrome Version 112.0.5615.49 (Official Build) (64-bit)
  • Operating system: Windows
@stanj98
Copy link

stanj98 commented Dec 24, 2023

Hey, have you found a solution to this?

@andrii-baran-nfgp
Copy link

Have you tried?

new Trix.Attachment({content : url, contentType:"image"})

@sejutaimpian
Copy link

function addImageUrl(url, caption) {
    const attachment = new Trix.Attachment({ filename: caption, url: url, contentType: "image/png" })
    element.editor.insertAttachment(attachment)
}

this worked for me.

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

4 participants