Elfinder: CKeditor Integration - Use Relative URL

Created on 22 May 2018  路  4Comments  路  Source: Studio-42/elFinder

I am new to elFinder and have integrated it with ckeditor 4. I have not been able to figure out how to force elFinder to use relative path and not the full URL.

Right now when selecting an image: "https://localhost.com/UserFiles/image/flag-field.jpg"

I need it to be: "/UserFiles/image/flag-field.jpg"

Any assistance is greatly appreciated!

question

Most helpful comment

@loracalyn It is one example.

managers : {
    // 'DOM Element ID': { /* elFinder options of this DOM Element */ }
    'elfinder': {
        getFileCallback : function(file, fm) {
            var m = fm.convAbsUrl(file.url).match(/^https?:\/\/[^\/]+(.*)/);
            window.opener.CKEDITOR.tools.callFunction((function() {
                var reParam = new RegExp('(?:[\?&]|&)CKEditorFuncNum=([^&]+)', 'i') ;
                var match = window.location.search.match(reParam) ;
                return (match && match.length > 1) ? match[1] : '' ;
            })(), m[1]);
            fm.destroy();
            window.close();
        }
        , height : '100%'   // optional
        , resizable : false // optional
    }
}

All 4 comments

@loracalyn You can edit that URL in the function of getFileCallback.

I apologize, but I've tried to figure out how to do this, but can not. Can you give me more to go on.

I see getFileCallback in my elfinder-cke.html file. How do I accomplish a relative path

(Again, I appreciate any help you can give. I am new at this!)

managers : {
    // 'DOM Element ID': { /* elFinder options of this DOM Element */ }
    'elfinder': {
        getFileCallback : function(file, fm) {
            window.opener.CKEDITOR.tools.callFunction((function() {
                var reParam = new RegExp('(?:[\?&]|&)CKEditorFuncNum=([^&]+)', 'i') ;
                var match = window.location.search.match(reParam) ;
                return (match && match.length > 1) ? match[1] : '' ;
            })(), fm.convAbsUrl(file.url));
            fm.destroy();
            window.close();
        }
        , height : '100%'   // optional
        , resizable : false // optional
    }
}

@loracalyn It is one example.

managers : {
    // 'DOM Element ID': { /* elFinder options of this DOM Element */ }
    'elfinder': {
        getFileCallback : function(file, fm) {
            var m = fm.convAbsUrl(file.url).match(/^https?:\/\/[^\/]+(.*)/);
            window.opener.CKEDITOR.tools.callFunction((function() {
                var reParam = new RegExp('(?:[\?&]|&)CKEditorFuncNum=([^&]+)', 'i') ;
                var match = window.location.search.match(reParam) ;
                return (match && match.length > 1) ? match[1] : '' ;
            })(), m[1]);
            fm.destroy();
            window.close();
        }
        , height : '100%'   // optional
        , resizable : false // optional
    }
}

nao-pon ... Thank you so much! I really appreciate your assistance!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CodeLyokoXtEAM picture CodeLyokoXtEAM  路  3Comments

ethaizone picture ethaizone  路  3Comments

DaeMonSx picture DaeMonSx  路  4Comments

mschlosser22 picture mschlosser22  路  4Comments

camgullo picture camgullo  路  3Comments