Availability: >= 3.0

Type: Object Method

Description: Registers a new HTML filter


editor.addHTMLFilterstring filtername, function function );

HTML filters are JavaScript functions that can be used to alter the HTML code generated by the editor.

They can be used to alter the format of code generated by the editor or to parse basic placeholder tags.


The name of the filter event which should call this function.

The JavaScript function that will perform the filter.


In the following example the first filter converts the template tag {site_url} to a URL when switching to design view so that images do not appear as broken images. The second filter converts the URL back into the {site_url} tag when generating source code.

var editor = WPro.editors['editorName'];

// Design view filter
editor.addHTMLFilter('design', function (editor, html) {
    return html.replace(/{site_url}/gi, "");

// Source view filter
editor.addHTMLFilter('source', function (editor, html) {
    return html.replace(/, "{site_url}");

To add filters for template tags you should use the templateFilter plugin

See also: