This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // If you want inserted images in a CKEditor to be responsive | |
| // you can use the following code. It creates a htmlfilter for the | |
| // image tag that replaces inline "width" and "style" definitions with | |
| // their corresponding attributes and add's (in this example) the | |
| // Bootstrap "img-responsive" class. | |
| CKEDITOR.on('instanceReady', function (ev) { | |
| ev.editor.dataProcessor.htmlFilter.addRules( { | |
| elements : { | |
| img: function( el ) { | |
| // Add bootstrap "img-responsive" class to each inserted image |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function string_to_slug (str) { | |
| str = str.replace(/^\s+|\s+$/g, ''); // trim | |
| str = str.toLowerCase(); | |
| // remove accents, swap ñ for n, etc | |
| var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;"; | |
| var to = "aaaaeeeeiiiioooouuuunc------"; | |
| for (var i=0, l=from.length ; i<l ; i++) { | |
| str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i)); | |
| } |