Hi all
I will try n describe my problem as best I can, in the CMS system we are currently using image urls and links are generated using the CMS tags which start with {{ and end with }}.
So for example if I add an image from the filebrowser the image url would be set to something like
{{image id='1' size='240x550'}}
which the CMS would then return a cached resized image at the relevant size (on output).
I have managed to get CK to swap these img src's with the right URLs to the files using fakeobjects, but this disables the ability to edit the image properties, the image context menu and also removes any stylings from the element. The code I am using is below...
I was wondering if anyone knew of a way around this problem. The only way I can thing so far is to recreate the image plugin, but I dont really want to do this if there is another solution.
So if anybody has any suggestions, it would be greatly appreciated.
Any feedback would be helpful.
Chippo
I will try n describe my problem as best I can, in the CMS system we are currently using image urls and links are generated using the CMS tags which start with {{ and end with }}.
So for example if I add an image from the filebrowser the image url would be set to something like
{{image id='1' size='240x550'}}
which the CMS would then return a cached resized image at the relevant size (on output).
I have managed to get CK to swap these img src's with the right URLs to the files using fakeobjects, but this disables the ability to edit the image properties, the image context menu and also removes any stylings from the element. The code I am using is below...
CKEDITOR.plugins.add('cms', { afterInit : function( editor ) { var dataProcessor = editor.dataProcessor, dataFilter = dataProcessor && dataProcessor.dataFilter; if ( dataFilter ) { dataFilter.addRules( { elements : { img : function( element ) { var dec = decodeURIComponent(element.attributes.src); var checks = ['url','image']; // looks for {{url }} and {{image }} tags var al = attribs.length; if((/^\{\{/).test(dec) && (/\}\}$/).test(dec)){ for(var i=0;i<2;i++){ if(dec.substr(2,checks[i].length).toLowerCase() == checks[i]){ var l = 3+checks[i].length; var opts = dec.substr(l,((dec.length-l)-2)) var elem = editor.createFakeParserElement( element, 'cke_cmstag', 'img' ); elem.attributes.src = do_attribs(checks[i],opts); // do_attribs() is a function I use to convert the cms tag to a url return elem; } } } } } } ); } }, requires: ['fakeobjects'] });
I was wondering if anyone knew of a way around this problem. The only way I can thing so far is to recreate the image plugin, but I dont really want to do this if there is another solution.
So if anybody has any suggestions, it would be greatly appreciated.
Any feedback would be helpful.
Chippo