Jump to content

CKEditor Custom Button audio tag for non-admins


The Old Man

Recommended Posts

Hi,

I added a custom button to CKEditor which when clicked inserts a standard HTML5 Audio tag into a post. These are standard HTML5 tags. All users can use the button in its permissions. Only admins can post HTML

<audio controls="">
		<source src="https://mysite.com/downloads/audio/effects/MD2_single.mp3" type="audio/mpeg"> Sorry, your browser does not support the audio element.
	</audio>

It works great for admins, the browser shows the playback controls and plays the mp3 when pressed even on an iPad, but some of the code is stripped out when members use it which is preventing them for using it, their post reverts back to the fallback text.

I thought there was an option somewhere to whitelist certain html tags when posting, but I can't find it.

Anyone know how to resolve this, please?

Link to comment
Share on other sites

IPS security measures restrict almost every HTML attributes and most elements, that being saved through CKEditor. but there is some ways to bypass, like using slimmer codes in HTML side, using JS for correction. same can be done with jQuery. which is I did that for this button.

With jQuery you can attach right sort of HTML elements and tags after page load.

Link to comment
Share on other sites

Well, since most HTML attributes can't be saved during posting and these parts are usually omitted, and since CKEditor's plugins mostly using HTML attributes for JS reference, some time with this kind of plugins, you can modify HTML line for specific CSS class then use this class for JS reference. because you can whitelist CSS class in IPS.

I haven't seen how your button works, so I assume lines won't be saved because <audio> tag and "controls" attribute. you can gave the audio line a specific CSS class, whitlist it. grab this one with jQuery and modify it with that. I'm not sure but I think it's gonna work.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...