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();
};
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

zipymonkey created an issue. See original summary.

pifagor’s picture

FileSize
1006 bytes

implemented the patch described above.

pifagor’s picture

Status: Active » Needs review
zipymonkey’s picture

Thanks @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.

anon’s picture

Status: Needs review » Needs work

See #4

zipymonkey’s picture

I 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.

zipymonkey’s picture

Status: Needs work » Needs review
Chris Matthews’s picture

The 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.