MCFileManager:JS options/insert filter

From Moxiecode Documentation Wiki

Jump to: navigation, search

Contents

Option: insert_filter

(Requires: 3.0.6)

This option enables you filter the data before it gets inserted into the form or TinyMCE. This filter function can change anything the URL of the file or the file size.

Example of usage in init call on page level

mcFileManager.init({
    insert_filter : function(data) {
        data.url = data.url.toUpperCase(); // Converts the URL to uppercase
    }
});

Example of usage in mcFileManager.open call

<script type="text/javascript">
function filterFunc(data) {
    data.url = data.url.toUpperCase(); // Converts the URL to uppercase
}
</script>
<a href="javascript:mcFileManager.open('example1','url','','',{insert_filter : filterFunc});">[Browse]</a>

Example of usage in tinyMCE.init call

This example shows you how to setup an custom insert filter function that converts the URL to upper case and then adds a custom item. It also displays how to use the new custom item in the insert template.

tinyMCE.init({
    filemanager_insert_filter : function(data) {
        data.url = data.url.toUpperCase(); // Converts the URL to uppercase
        data.custom.somekey = 'Some title'; // Add custom item
    },
    filemanager_insert_template : '<a href="{$url}"><img src="{$custom.thumbnail_url}" width="{$custom.twidth}" height="{$custom.theight}" title="{$custom.somekey}" /></a>'
});
Personal tools