Problem/Motivation
The base_path of the site is always prepended to the path of the inserted link when linking to a file using IMCE. There was a patch for the 7.x-2.x branch but that was closed and this issue was never resolved. See node/1221606.
To Duplicate
Try to insert add a link to a file using IMCE where Insert Paths as: is set to Raw Paths. The base_path of the site is always prepended to the inserted link.
Proposed resolution
Need to modify the Drupal.linkit.IMCECallback callback so that the links that are inserted according to the Insert method settings for the given profile. Maybe something like this:
Drupal.linkit.IMCECallback = function(file, win) {
var instance = Drupal.settings.linkit.currentInstance;
var data = {
path: file.relpath,
attributes: {}
};
if (instance.helper == 'field') {
link = win.imce.decode(Drupal.linkit.getInsertPlugin(instance.insertPlugin).insert(data, instance));
} else {
// TODO: Not sure why the above doesn't work for editors...
link = Drupal.settings.basePath +
Drupal.settings.linkit.publicFilesDirectory + '/' + file.relpath;
}
Drupal.linkit.populateFields({path: link});
win.close();
};
Comments
Comment #2
pifagorimplemented the patch described above.
Comment #3
pifagorComment #4
zipymonkey commentedThanks @pifagor for making this a patch I was able to apply it to v3.5 without issue. We might want to set this to Need work because the patch doesn't handle profiles used with editors.
Comment #5
anonSee #4
Comment #6
zipymonkey commentedI had to make the url_method available to the javascript callback so the url returned by IMCE could be correctly formatted.
Anyway, the attached patch seems to work for me using linkit-3.5.
Comment #7
zipymonkey commentedComment #8
chris matthews commentedThe 2 year old patch in #6 to linkit.dashboard.js and linkit.field.inc applied cleanly to the latest linkit 7.x-3.x-dev, but still needs community review & testing.