0

How to allow html5 data attributes in tinymce editor? Tinymce removes the custom attributes specified to a tag. How can I prevent tinymce from removing it?

1
  • Did the answer below solve your issue? If so you should select it as correct so others don't invest time trying to answer the question and if others find your question via search they will know the answer. Commented Feb 13, 2017 at 16:15

1 Answer 1

2

You can allow these in TinyMCE by adding the extended_valid_elements option to your TinyMCE configuration. For example you could do this:

extended_valid_elements: "*[*]"

...which should allow any tag or attribute or you can be more specific about what you want to add:

extended_valid_elements: "+@[data-options]"

This should specifically add support for data-xxx attributes on any tag but would otherwise not change what TinyMCE allows.

Note: I note you have the WordPress tag on this question. It is possible that while TinyMCE would allow a tag or attribute that WordPress would remove it on save ... if you see the attribute in the "code" view but not after its saved that is likely a WordPress issue.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.