I’m embedding a video.

I have the video button set up for my Redactor field. I use it to insert a video element.

When I save Redactor strips the code out and replaces it with an empty figure element.

Any idea how to stop Redactor doing that?

1 Answer 1


I would personally advise a matrix field and allow a mix of block types instead of trying to push code into the Redactor field. This can open you up to security vulnerabilities.

To learn more about the Matrix field type you can see the docs: https://craftcms.com/docs/4.x/matrix-fields.html

That being said if you really want to open up the possibility of adding video embed code into your Redactor field you can check if the config settings include "plugins:" ["fullscreen", "video"] and "allowedTags": ["iframe"].

To check this it would be /web/config/redactor/[whatever json you want to apply this to]

You can create multiple json configs for Redactor as well. https://github.com/craftcms/redactor

  • Thanks — matrix isn’t an option in this circumstance, it would mean recoding the templates. The video button is enabled, and works fine with YouTube and Vimeo embeds, just not valid HTML video code.
    – mitrol
    Commented Jan 15 at 12:00
  • You could also try adding "html" to the buttons array in the config setting json file. I hope this helps!
    – kelly
    Commented Jan 15 at 18:28
  • Thanks @kelly, but that’s there too. I ended up turning off the HTMLPurifier for the field, but it’s not exactly ideal.
    – mitrol
    Commented Jan 17 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.