Search code examples
htmldjangodjango-cms

django-cms removing <img> tags from text content


I'm using django-cms, and I add a piece of text content (using the standard text plugin) to a page. Then on that piece of text, I go into html mode and add <img src="/foo/bar.png" /> and save the plugin and save the page.

On the site, now, I see the page changes I've made, but the img tag has been stripped out.

Any idea why this is happening? I've tried wymeditor and fckeditor and it happens under both.


Solution

  • In Django, strings are sanitized before being output onto a webpage by default. I suspect Django-CMS treats plugins like unsanitized user data, so the Django Template system strips out an HTML characters from the plugin.

    Django Template Docs: http://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs

    Note the very first item, autoescape. I suspect plugins are being run through that filter.

    Sorry, I don't have any more specifics. I'm not a Django-CMS guy.