I use Link to show Sibelius scores and pdf-files in nodes.
To get the precise path I use CKEditor->Link (IMCE) to browse the path. Then I copy the path from the field, closes the IMCE and inserts the path in the Link field.
It would be easier if Link could use IMCE to browse for existing files on own server directly.
Is that possible?

Comments

jcfiala’s picture

I suppose it's possible, but I don't have the time for it myself. It sounds like a neat idea for a patch, though.

jcfiala’s picture

Title: Browse server ability » Link IMCE Integration
ufku’s picture

A solution in theme layer:

function THEMENAME_link($element) {
  static $imce_access;
  if (!isset($imce_access) && ($imce_access = (bool) module_invoke('imce', 'access'))) {
    drupal_add_js('
(function($) {Drupal.behaviors.imceLinkFields = function(context) {
  $.each(Drupal.settings.imceLinkFields || [], function(i, fid) {
    var $field = $("#" + fid, context);
    if ($field.size() && !$field.is(".imce-processed")) {
      var $button = $(document.createElement("input")).attr({type: "button", value: "Browse"}).click(function() {
        window.open("' . url('imce', array('query' => array('app' => 'field'))) . '|url@" + fid, "", "width=760,height=560,resizable=1");
      }).addClass("imce-processed").insertAfter($field);
      $field.width($field.width() - $button.width()).css("display", "inline-block").focus(function() {
        var val = this.value, bpath = Drupal.settings.basePath;
        if (val.indexOf(bpath) == 0) {
          this.value = val.substr(bpath.length);
        }
      });
    }
  });
}})(jQuery)', 'inline');
  }
  if ($imce_access) {
    drupal_add_js(array('imceLinkFields' => array($element['#id'] . '-url')), 'setting');
  }
  return theme_link($element);
}

The js snippet can also be added to script.js

yukare’s picture

Please, can not you change this to drupal 7 and make a patch to use in the module, not in theme?

dqd’s picture

Status: Closed (fixed) » Fixed

sadly no - temporarily. It has to be clarified if there is any security issue possible on it. A link field in D7 should be very careful with new features since it is an elementary field. This should be discussed with D7 security team members involded.

But since this issue is half a year old I will close it until somebody feels to reopen it.
thx 4 understanding and special thx for the provided snippets and reports! much appreciated.

Priority: Major » Normal
Status: Active » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.