Just as #540694: Compatibility with Pathologic module we would like to somehow alter the slash prefix that IMCE inserts. The module we are maintaining, Linkit, currently enables users to browse files with IMCE. However, IMCE returns a slash "/" prefix which we would like to alter. (If Drupal is installed in a subdir the prefix is "/subdir/")

In our case we would just like to remove the slash, but there could be other situations where it would be better to have an absolute URI prefix or something completely different. The IMCE "API" has an "url" parameter which tells IMCE to insert the url to a certain element. Could there possibly be an optional prefix parameter as well? If it it's not specified, then let IMCE decide (i.e. normal behavior). In that way it wouldn't interfere with any current functionality.

Comments

ufku’s picture

You may try sendto integration where you manually set your field content with the provided file object. You will also have access to imce variables and methods.

Quoting from readme.txt

- USING sendto:
You can point a predefined function to which the selected files are sent.
When the URL is like "app=myApp|sendto@myFileHandler", IMCE calls "myFileHandler" function of the parent window with file and window parameters.
function myFileHandler (file, win) {
  $('#urlFieldId').val(file.url);//insert file url into the url field
  win.close();//close IMCE
}
Avaliable file properties are: url, name, size(formatted), width, height, date(formatted), bytes(integer size in bytes), time(integer date timestamp), id(file id for newly uploaded files, 0 or integer), relpath(rawurlencoded path relative to file directory path.)

Here is how to derive file uri as its stored in db.

var uri = win.imce.conf.scheme + '://' + win.imce.decode(file.relpath);

Note that it's more reliable to decode the relative path at server side using rawurldecode() instead of js imce.decode().

Moreover, url('imce') serves files using the default scheme. If you want IMCE list files of a specific scheme you should use url('imce/SCHEME').

anon’s picture

+1

betamos’s picture

Category: feature » support
Status: Active » Fixed

Thank you very much, I have tried this now and it works perfect. I'm happy with this solution, so I'm changing status to support request for now. If anyone still feels that the behavior of IMCE should be different, please reopen this ticket.

Thanks again for the sophisticated reply.

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