Would be nice, if users can use IMCE for file browsing instead of default media browser.

Here is a patch to add IMCE integration to media browser. You can choose between original media browser and IMCE.

The second little patch just add a "cancel" icon to IMCE (1.3 or dev). BTW: Everything work without the cancel icon.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

szaszg’s picture

Here is a new, cleaner better patch for the 7.x-1.x-dev 2011-Apr-11...

JacobSingh’s picture

On the whole, this is good code. I've made a few comments below.

Architecturally though, I don't think this is the right approach. @james.elliott is reworking a lot of the bad JS in the media browser code to make it easier to work with, and I think as part of that he's going to consider how to support different browsers.

We're looking at creating a views based browser for instance, although this would only affect the library tab, not every tab. Still, if we are going to support more than one option for browsers, we should make that a pluggable hook, not hardcode "use_imce" in various places. Perhaps as a start to get this in so people can use it, we could build two patches.

One would be a new module in the contrib directory "media_imce" which would contain all the code you've put in here. And the other would be patches to media which would allow the user to pick a browser to use. I think this means a variable to set the default browser site wide and a setting at the element level to choose the browser. So:

 $form['media_add_link'] = array(
  '#type' => 'media'
  ''#media_options' => array(
      'browser' => 'imce',
      'global' => array(
        'types' => array_filter($instance['widget']['settings']['allowed_types']),
        // @todo: Not implemented
        'schemes' => $instance['widget']['settings']['allowed_schemes'],
      ),
    ),
);

The default would be site wide set to a variable, but depending on where the element was added it could choose a specific browser.

Thoughts?

diff -rNu media.20110411/includes/media.admin.inc media.new/includes/media.admin.inc
--- media.20110411/includes/media.admin.inc	2011-04-11 09:00:40.000000000 +0100

Patch should start inside the media module directory.

+++ media.new/js/media.popups.js	2011-04-13 20:38:48.331718609 +0100
@@ -129,6 +134,75 @@
+  mediaIframe.css('width', '98%');

Is this going to work with different themes?

Powered by Dreditor.

JacobSingh’s picture

Status: Active » Needs work
szaszg’s picture

Here is a new reworked patch:

- new "sub" module `media_imce'
- new hook in media.api.php: hook_media_browser_info()
- media_browser_build_media_item() go into `media.module' in order to "sub" modules can use it
- media_media_browser_info() and media_browser_media_callback() implemented in `media.module'
- radio input for selecting media browser (site wide) in `includes/media.admin.inc' (this use the hook...)
- in `includes/media.browser.inc' media_browser_js() now include the selected browser settings and js file (this use the callback...)
- the (builtin/default) browser popup code removed from `js/media.popups.js'
- the (builtin/default) browser popup code inserted into `js/media.popups.media.js'

szaszg’s picture

"Is this going to work with different themes?" -- I think so, because this set the IFRAME width where IMCE pop ups. If we leave the IFRAME width as is than IMCE's scroll bar at the right shown only partially.

aaron’s picture

this is awesome, thanks szaszg! it's definitely been a goal of the project since the beginning to have media allow for pluggable browsers. it's great to see a push in that direction, with a usable alternative!

szaszg’s picture

Here is a patch for current dev.

szaszg’s picture

Here is an updated patch for current dev.

aspilicious’s picture

Look again at the coding standards and try to remove tabs, white spaces, "no newline at end of file" warnings.
You should try dreditor (in combination with firefox and chrome) to checkout your patch in here.

szaszg’s picture

"... try to remove tabs, white spaces, "no newline at end of file" warnings." sorry, but how can i do it exactly?

Tabs??? There is no any tab in the whole media/media_imce code.

In the patch the tabs came from the diff itself, because it separate header elements with tabs... what is the problem????

This patch isn't a "cosmetic" patch of the code, so i do not think I have to trim the "original" code... and I try to avoid "tabs" and "extra" spaces in my code already.
The "no newline at end of file" warning came from the "original" code because the original "media.api.php" file has no newline at the end... so i can do nothing with it.

"You should try dreditor" .. sorry, but dreditor only for drupal 6.x and i use drupal 7.x.

So I try 'coder' on my patch and this report only 9 "error": 7 with severity minor and 2 with normal. One of the normal is a total miss, because the whole thing is in a comment and 'coder' talk something about string concatenation. Most of the errors came from the "original" code (this false error too), so after fixing, 4 minor and 1 normal "error" left.

Just to compare my patch and the "original" code: 'coder' found 12 error with critical severity and about 60 with normal severity in the original media module code...

Here is a revisited patch:

Vasu’s picture

+1

aspilicious’s picture

Dreditor is an chrome and firefox extension, if you install it there will be a review button next to your uploaded patch if you click it you get red warnings when you did something wrong like using trailing whitespaces.

As it is a browser extension it doesn't matter what kinda version of drupal you're using :)

arthurf’s picture

@szaszg since media 7.x-2.x is going to have some significant rewrites to the browser and surrounding JS should we hold on this patch until that gets worked out?

szaszg’s picture

Uhum... I created a sandbox module (http://drupal.org/sandbox/szaszg/1296442) which provides a Media browser plugin with IMCE.

CarbonPig’s picture

subscribe

michiellucas’s picture

when installing the sandbox module i get following error

Fatal error: Class 'MediaBrowserPlugin' not found in /www/sites/all/modules/contrib/media_browser__imce/media_imce.module on line 53

Using latest release of media

jisuo’s picture

Is there any update on this integration?

mgifford’s picture

Ping... Been over a year now, can we assume this isn't getting in the next release?

sonicthoughts’s picture

bummer - made sense.

lesleyfernandes’s picture

Issue summary: View changes

subscribe

mgifford’s picture

Status: Needs work » Needs review

Generally folks are encouraged to Follow rather than "subscribe".

Anyways, it's been a while now. I do wonder if the bots have been engaged in doing an automated review.

The last release was from 2014-Jan-08 so it's over due for a new stable release.

The last submitted patch, media-7.x-1.x-dev.2011-Mar-06-IMCE.patch, failed testing.

The last submitted patch, imce-7.x-1.3-cancel.patch, failed testing.

The last submitted patch, imce-7.x-1.3-cancel.patch, failed testing.

The last submitted patch, 1: media-7.x-1.x-dev.2011-Apr-11-IMCE_2.patch, failed testing.

The last submitted patch, 4: media-7.x-1.x-dev.2011-MAY-10-IMCE.patch, failed testing.

The last submitted patch, 7: media-7.x-1.x-dev.2011-MAY-26-IMCE.patch, failed testing.

The last submitted patch, 8: media-7.x-1.x-dev.2011-MAY-26-IMCE-1.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 10: media-7.x-1.x-dev.2011-MAY-26-IMCE-2.patch, failed testing.

Chris Matthews’s picture

Status: Needs work » Closed (outdated)

Closing this issue as outdated. However, if you think this issue is still important, please let us know and we will gladly re-open it for review.
sincerely,
- the Drupal Media Team