Wagtail: Inserting links to images in rich text field

Viewed 385

I have a need to insert links to images held in the CMS in rich text editor, similar to how documents are inserted. However, by default images are inserted as embeds and requires an extra step to choose a format. How I could override the "insert image" button in rich text editor to work similar to documents and insert images only as a link?

In other words, the current document chooser provides the following database entry:

"value": "<p><a id=\"1\" linktype=\"document\">Download pdf</a></p>"

I would like to have something similar to images as well, for example:

"value": "<p><a id=\"1\" linktype=\"image\">Download image</a></p>"

Technically I don't care about the database representation so I'm also okay with a solution which only changes the API output to similar format as documents have, for example:

<p><a href=\"/documents/1/document.pdf\">Download pdf</a></p>

However, I still would like to get rid of the unnecessary step in CMS to choose image format.

Any suggestions?

0 Answers
Related