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?
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