Comments

JacobSingh’s picture

Sweet! This is a nice start.

Do you see how creating it as a field will make the code better? Make sure you look at EntityFieldQuery when coding up the filter part.

A couple quick nits:

+/**
+ * put files into default folders if not yet in any folder
+ */
+function media_browser_plus_enable()
+{
+	
+}

This needs to be written... I'm a little concerned about the performance of effecting every media item as we update, let's think about this some more. Perhaps we don't need to to update it, and the query code will just assume the default if it is not set? Nah... better to set it.

+
+/**
+ * 
+ * 
+ */
+function media_browser_plus_uninstall()
+{
+	field_delete_field('field_folder');
 }

If we do this here, we should probably do it for other fields created by this mod.

Sebastian.Buesing’s picture

Hey,

well that was quick. Yeah the code really does look better like this. Glad you didn't find the tiny error I had in the first patch :-)

effulgentsia’s picture

Yay, our first issue, and fellow contributor! Welcome, Sebastian!

Related to this, I added a meta issue: #969062: Decide on architectural approach to field management.

Sebastian.Buesing’s picture

Issue tags: +tag media
StatusFileSize
new9.35 KB

Hi,

ability to select folders and create/select tags is now included.

I couldn't test it for the multiple file upload form, since that doesn't work on my drupal install (7.0-dev). I was told that all one needs is the "Plupload integration module" enabled, but by doing so I get a new form whithout any means to add a file. The usual file upload input simply vanishes and is replaced by nothing. :-(

JacobSingh’s picture

Perhaps you didn't follow the install instructions? Plupload requires a 3rd party library. See the INSTALL.txt or README.txt. Also, might be good to file a ticket to write something which warned people about this.

-J

Sebastian.Buesing’s picture

Hi,

works like a charm if you do this:

actually read the README and do as told:
To install Plupload:
1. Download plupload from http://plupload.com
2. Unzip it in this directory, should look like plupload/plupload

apply this patch to plupload:
http://drupal.org/files/issues/plupload-920038.patch

tagging and (whatever the act of putting sth in a folder is, "folderising" doesn't seem to be a word.) works great for multiple files. :-)

Greetings,
Sebastian

P.S.: Forgot to mention you need to manually resized the iframe using firebug to actually send the form, because otherwise you can't reach the submit button ;-)

Jackinloadup’s picture

Sebastian just an FYI. Ine way i got around that iframe resize bug you mentioned was to switch to a different tab in the uploader, like web, then back to upload. I haven't investigated this bug yet. I'm pretty sure there is not an issue for it yet either.

I can't wait to try out the folders.

Thanks for all the hard work everyone!

JacobSingh’s picture

James.elliot knows something about this, he's been working on it. We try to resize the window to fit its contents, and IE lags behind a bit in firing the event handler, or something like that.

JacobSingh’s picture

Nice, I just tested this out! I see what you mean about the window resizing.

Here's the issue for that if someone has ideas:
#917684: plupload tab of media browser too short in IE

Fixing that is dependent really on committing this since it will make it look like poo. :(

In regards to the patch itself, a couple general things:

-- Read http://drupal.org/coding-standards
In particular, you're indentation settings in your IDE are wrong.

-- For the folder list, use an indented select list like the one provided by the taxonomy module. I don't know off the top of my head where to find this, but I think it is in options_field_widget_form();
This might be a bit of a complex approach, but if you can figure it out, it will provide a more consistent interface for this field. Maybe something with
field_attach_form('media', $fake_item_with_type_set, $form, $form_state);
But just a WAG (Wild-Ass Guess).
Eventually, we'll probably want to build a custom interface since these type of select boxes are terrible for large hierarchies.

Best,
Jacob

JacobSingh’s picture

Status: Needs review » Needs work
james.elliott’s picture

I'm taking a fresh pass at #917684: plupload tab of media browser too short in IE so I wouldn't consider that blocking

Sebastian.Buesing’s picture

Status: Needs work » Needs review
StatusFileSize
new6.37 KB
new18.82 KB

Hi,

I have another patch for you guys to rip apart with constructive criticism:-)
This one is in a way still a working progress but already functional. I have added a drag and drop interface to the media grid view, which allows to drag media into different folders and load folder contents.

First off if you want to test this, you need to also unzip the appended zip archive in the mbp root directory.

The following functions

_media_browser_plus_folder_hierarchy_list()
_media_browser_plus_create_relationship_list()
_media_browser_plus_folder_hierarchy_list_helper()

are a basicly some older functions I reused for drupal, but I'd still like some feedback on those, maybe their is also some internal stuff that could be better used instead.

Also I wasn't really sure how to handle an AJAX Request (for example the one I use to load the images) properly in Drupal and since I'm somewhat under pressure to finish this, I used the most drupal like way I could think of, that suited my need. However I'd love to take a second look and redo this part as well.

Another part is that I haven't had time to fully investigate is how to load/filter media, meaning that I'd love to know how load entities (i.e. media entities) and pass on a field value condition for the load. Of course I'll look myself for a solution, but since I'm on the road tomorrow maybe sb is faster :-)

That'll be all for now.

Greetings,
Sebastian

JacobSingh’s picture

Wow! You've been busy. Btw, I just unblocked you I think on the window height issue.

I won't be able to look at this for a few days. Could you please try to start posting screenshots / mockups? For new features which impact the UI, it makes everyone's life easier if you can send up your plans visually before you start coding. Then if there is any discussion that needs to occur, it's not frustrating because you haven't already built the damn thing :)

I understand though that sometimes, you have to just start building it to know what it is eventually going to look like. At any rate, I'll get to this as soon as I can, and if you don't hear from me by Monday, please ping me.

Thanks!
Jacob

JacobSingh’s picture

Before I review any further, please review the coding standards doc. It is GREAT you are contributing, and it pays off big time in the long run to get your addition into the module and not maintain a fork, but you've got to follow the conventions and use coder module. I know it's annoying, I've gotten this same lecture several times, but the people who gave it to me (although often rude and petty) were right in this regard.

I noticed right away using:

foreach() 
{

Curlies go on the same line.
And stuff like:

return array(
+      '#type' => 'select',
+      '#language' => LANGUAGE_NONE,
+      '#title' => t('Media Folder'),
+      '#fiel

(indentation is set incorrectly).

Please take a moment (it won't take but 10minutes) to just check the indentation, spacing, etc and try to submit a clean patch.

NOTE: I will still review the functionality, etc anyway I'm not a stickler like some people, but I won't commit it till it's at least close.

Sebastian.Buesing’s picture

Hi,

just wanted to tell you that your comments regarding coding style aren't falling on deaf ears. I actually spent a long time the other day trying to remove all none-drupal cs compliant lines. Guess I didn't find them all, my bad I'll recheck when I get a chance and reupload te patch.

Greetings,
Sebastian

luke_b’s picture

Peter has written a nice Drupal coding standard sniff for PHP_CodeSniffer which you can use with Eclipse, it will find all the (non-compliant) lines automatically. http://drupal.org/node/897116 Have a look!

Regards,
Luke

Sebastian.Buesing’s picture

Hi Luke,

Peter and I already spent some time trying to get his clever little sniffer to work without success. I am in the process of rearanging my developement enviroment which might enable it to work in the future,but first I have to clean up this patch ;-)

Greetings,
Sebastian

Sebastian.Buesing’s picture

Hi,

added 3 files, which sum up pretty much everything I did so far, except for the management of folders (add/edit/delete/sort) which is held back by some menu bug :-(, but so far you can just use the taxonomy interface.

I'll be making some UI Screeshots for some inteface discussion on the weekend and should also be able to work some more on filtering/pagination.

Note:
media-mbp-js-patch-1-2010-26-11-1710.patch (patch for the media module change js behaviour)

and the rest belongs to the mbp module. Zip is to be unzipp in the root of the module.

Greetings,
Sebastian

P.S.: I really looked a lot over this now in terms of coding principles. I sure hope I didn't overlook anything :-)

Sebastian.Buesing’s picture

StatusFileSize
new34.58 KB

Hi,

created a function to replace the standard way to load media entities which didn't allow for filtering against field values. List view now allows to filter via folders. Paging however is still in progress.

use files:
- media-mbp-js-patch-1-2010-26-11-1710.patch
- media_browser_plus-1-2010-26-11-1710_additional_files.zip
from previous post to fully apply this patch.

Greetings,
Sebastian

james.elliott’s picture

This is really starting to shape up.

There are some minor formatting issues in media_browser_plus.admin.js that I'm not too concerned about. (double indenting)

However, the structure in media_browser_plus.admin.js is fine as jQuery but Drupal handles its jQuery integration is a specific sense. Drupal has its own behavior system that will attach and detach behaviors on page load. jQuery(document).ready() is therefore unnecessary and contrary to the best practices for jQuery in Drupal. This is discussed partway down the page here http://drupal.org/node/756722

I would also recommend to move away from anonymous closures in your javascript. They make stack traces less descriptive and create a circular reference which can lead towards memory leaks and poor performance. This is discussed in the blog post here. http://blog.iconara.net/2006/04/17/wonderful-closures-evil-closures/

james.elliott’s picture

I'm also noticing that you use the each() function in jQuery when it is unnecessary.

$item.parent().children('ul').each(function(index) {
  // and toggle their display
  $(this).toggleClass('hidden');
});

This could just as easily be written like so

$item.parent().children('ul').toggleClass('hidden');

The toggleClass() will apply to all of the children, there is no need to use each() to iterate through them.

Sebastian.Buesing’s picture

Hi,

tanks a lot for the feedback. I'll get on it on wednesday. Can't wait to use your input, because I agree thats its becoming quite the nice addition.

Greetings,
Sebastian

james.elliott’s picture

StatusFileSize
new33.54 KB

I did some work on this yesterday.

- I rewrote the Javascript to match Drupal's implementation and use the power of jQuery.

- I rewrote the AJAX callback for media_browser_plus_thumbnailsJSON() to be a page callback and not a form build operation

- I altered the CSS file to match Drupal's CSS style guide.

Sebastian.Buesing’s picture

Hi,

thanks for the patch, but didn't you forget to add the js & css file, so one can actually test the changes you made to thoose or are they not quite finished?

Greetings,
Sebastian

james.elliott’s picture

StatusFileSize
new40.48 KB

Duh, I forgot to add the -N switch to my cvs diff.

New patch attached

Sebastian.Buesing’s picture

Hi, I didn't go through the complete patch, but one thing that came to my mind from the start was that with your new media_browser_plus_thumbnailsJSON() code you might have a typo concerning your folder condition, which will load only the items with the folder id 1 and (scroll down)

function media_browser_plus_thumbnailsJSON(){
  if($_POST['folder'] || $_GET['folder']){
    //
    $post = $_POST['folder'] ? $_POST['folder'] : $_GET['folder'];
    $folder = (int) (str_replace("folder_load_", "", $post));

    $query = new EntityFieldQuery();
    $query->fieldCondition('field_folder', 'tid', 1);  // shouldn't it be $folder instead of 1 here?
    $results = $query->execute();

    $fids = array();
    foreach($results['media'] as $result) {
      $fids[] = $result->fid;
    }
    
    $media_entities = entity_load('media', $fids);
    $return = '';

    foreach($media_entities as $media){
      $return .= '<li fid="' . $media->fid . '">';
      $return .= drupal_render(media_get_thumbnail_preview(media_load($media->fid), TRUE));
      $return .= "</li>";
    }

    // append overall result count
    $return .= "<li id=\"resultCount\">". count($fids) ."</li>";
    // replacing the false destination
    print str_replace("thumbnailsJSON", "thumbnails", $return);
  }
}

secondly why not use the new function I provided to filter/load media?

media_browser_plus_load_multiple()

like so:

$conditions = array();
$conditions[] = array("field" => array("field_folder", "tid", array($folder), "IN"));
$media_entities = media_browser_plus_load_multiple(array(), $conditions);

I'll have a look at the rest later this evening or tomorrow, but I just wanted to point out this first obvious thing, since I wanted to know if you have a problem with the new function or if you just overlooked it.

Greetings,
Sebastian

Sebastian.Buesing’s picture

Hi,

did find a few mistakes in your patch, changed them and merge the whole patch with my latest stable version. Enjoy and thanks again for the work you put in. I can really see the befinits of the changes you made to the Javacript code.

I tried the -N switch too with fakeadd, but the screwed up alot so once again I did had to add a zip file :-(, but I'll try again next time. ;-)

Greetings,
Sebastian

james.elliott’s picture

Good catch on the folder always being 1. I had used that for debugging and forgot to fix it before I rolled the patch. And I didn't realize you had added a media_browser_plus_load_multiple(). That looks promising.

I should have some time on wednesday to take a closer look at the state of the patch. I think I can even make a project branch so that we can commit the files there and no longer have to worry about the zip folder while still keeping the main branch viable.

Sebastian.Buesing’s picture

Good catch on the folder always being 1. I had used that for debugging and forgot to fix it before I rolled the patch. And I didn't realize you had added a media_browser_plus_load_multiple(). That looks promising.

Actually there were some more like that, but I rather just fixed them than point everyone out.

I should have some time on wednesday to take a closer look at the state of the patch. I think I can even make a project branch so that we can commit the files there and no longer have to worry about the zip folder while still keeping the main branch viable.

That would really be cool. If you need anything from me to make that work please let me know asap :-)

Sebastian.Buesing’s picture

Hi,

my latest work including some improvements in the UI.

How is it comming with the project branch?

Greetings,
Sebastian

james.elliott’s picture

Sorry about the delay, I've been completely swamped. I'm going to cut a branch today.

james.elliott’s picture

I cut a stable branch without your patch and then committed everything in #30 to HEAD for development

benanderson’s picture

subscribe

benanderson’s picture

Great work on this guys, thanks!

The UI enhancements are great, but the only thing I can't seem to get working is creating new folders. Right now "Media Root" is the only option. Am I missing something, or is this a known issue?

Sebastian.Buesing’s picture

Hi,

you're not missing anything. Folder management is already developed but not yet in a patchable fashion. I'll try to add the latest state on next wednesday. For now you can manage your folders in the admin menu under structure -> taxonomy -> media folders.

Greetings
Sebastian

jonaswouters’s picture

subscribing

camdarley’s picture

subscribing

deepbluesolutions’s picture

ready to help test once dev version can be rolled, good work on such a key feature

mrfree’s picture

@sebastian using your patch I can create new folder and select one during media upload but I can't browse the library, I mean it's still a big repo that doesn't consider the taxonomy "Media Folder" structure

Sebastian.Buesing’s picture

Hi,

have a look here:

http://drupal.org/node/1038062#comment-4113282

I guess that is what you want/mean?

Greetings,
Sebastian

mrfree’s picture

Yup, exactly :)
But if I select an image, adds it to the basket and click on "continue with media basket selection" I simply return on the upload tab and nothing appears in the tinymce editor

Sebastian.Buesing’s picture

Well if you read the linked issue completely you'll notice I mentioned that this feature isn't working yet and I'm looking for help getting it done ;-).

Please continue the discussion of that feature in the linked issue ;-)

JacobSingh’s picture

Status: Needs review » Needs work

You'll need update functions for this to work on existing sites I think

vogre’s picture

StatusFileSize
new74.34 KB

This is the version with working selection.
I added "select" button to bypass media basket.
Not sure if it is better than the version that Sebastian made.

vogre’s picture

Actually I find your approach quite strange. Why don't you use the same technique for grid rendering as media_browser does? Rendering grid in js from JSON'ed media entities?
I had to make additional server call to get required data.
The other issue with Library Plus is lack of filtering by allowed media type.

Sebastian.Buesing’s picture

@vogre:

thanks for your contribution. I haven't tested it yet, but I'm sure if you say it works it'll work :-)

As far as using JSON goes: It was intended from the start, but I wasn't that familiar with JS in the beginning as I am now and I'm happy to change the current loading method to use JSON the same way the current media library does. I think I'll have this up and running later today.

Once again thanks for helping and please criticise more to make this module even better ;-)

@Jacob:

Not sure what you mean with your post.

Sebastian.Buesing’s picture

Status: Needs work » Needs review

Hi,

I did finished it last minute (because I've to catch a bus in about 2 minutes). You'll find it here:
https://github.com/Buesing-Sebastian/Drupal---Media-Browser-Plus

Happy Testing ;-)

P.S.: Its not yet finished, but its working. I'll certainly make some improvements to the UI and add media_type support.

camdarley’s picture

First, thanks you very much. This is great!
There is a few issue i noticed:
- I can't delete medias. When i select medias and click "delete" the page reload, but nothing happen. The drupal's error log doesn't report anything.
- If there are medias in the media basket, when i click on "delete", the media basket's content start downloading.
- in "list" mode, media's deletion works
- if I click on the "list" view button, when i quit media overview's page, the button is on "list" mode when i come back, but the view is in thumbnail mode (not a big issue but that could be confusing)
- overlay positioning is wrong when i want to attach media to a field or to a wysiwyg editor. It's in the top left corner instead of page's center

That's all for now. (tested on Safari and Firefox)

Sebastian.Buesing’s picture

First, thanks you very much. This is great!
There is a few issue i noticed:
- I can't delete medias. When i select medias and click "delete" the page reload, but nothing happen. The drupal's error log doesn't report anything.
- If there are medias in the media basket, when i click on "delete", the media basket's content start downloading.
- in "list" mode, media's deletion works

fixed in latest version

- if I click on the "list" view button, when i quit media overview's page, the button is on "list" mode when i come back, but the view is in thumbnail mode (not a big issue but that could be confusing)

I'll have a look.

- overlay positioning is wrong when i want to attach media to a field or to a wysiwyg editor. It's in the top left corner instead of page's center

I tried to make the overlay a bit bigger but that feature is as you did see not quite perfected. Please upload a screenshot with browser(+version) if you run into an error like this please.

camdarley’s picture

I confirm that the first three issues are fixed with the latest version. Thanks !
About the position of the overlay, that's not a critical issue, but it's a strange behavior anyway.
I attached a screenshot: as you can see, the box is in the left top corner of the page. Before updating, it was at the absolute center. It's annoying when the image fields is at the bottom of the page because users have to scroll to the top to see the box.
Tested on Safari 5.0.3 and Firefox 3.6.14.

camdarley’s picture

StatusFileSize
new197.3 KB
Sebastian.Buesing’s picture

Hi,

I guess I used the absolute top position when I should have used the relative position the user has scrolled to. I'll fix this first thing tomorrow morning.

Sebastian.Buesing’s picture

Hi,

should work on most (if not all) browser now in the current version. Tested on windows machine in chrome, ff, safari and IE8.

camdarley’s picture

Hi,

Work perfectly well for me (Safari and Firefox). Great job! Thanks again.

james.elliott’s picture

This is looking really good. I've created a "folders" branch in git to continue developing this.

One thing I did notice when taking a quick look was that this appears to no integrate properly with the plupload feature of the media module. There is some sort of JS error when adding files.

james.elliott’s picture

Status: Needs review » Fixed

The problem appears to have been an outdated version of plupload on my end. I'm going to mark this as "fixed". That way we can continue to improve this in smaller more easily tested, reviewed, and committed changes.

vogre’s picture

Folders branch is broken.
Missing 'include' directory, media_browser_plus.admin.inc media_browser_plus.folders.inc, etc

Also there is a bug in _media_browser_plus_has_unsorted_media function which prevents display of the Unsorted folder.

The correct code is:

function _media_browser_plus_has_unsorted_media(){
// loading media
$entity_controller = entity_get_controller('media');
$media_entities = $entity_controller->load(FALSE, array(), 0, 100);

Can't make a patch because there is no working version and i don't understand what repo and branch is active now:(

anavarre’s picture

Subscribing

dmsmidt’s picture

sub

Sebastian.Buesing’s picture

Hi vogre,

does this error still occur when using this "branch":

https://github.com/Buesing-Sebastian/Drupal---Media-Browser-Plus

the function is more or less an relict of previous versions. Now there shouldn't be no more unsorted media, because all media is assigned to a folder via batch process on enabling the module. I'll remove it shortly.

Greetings,
Sebastian

Status: Fixed » Closed (fixed)

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

jason.fisher’s picture

+1

slashrsm’s picture

Where is main development of this branch going on? On github or on "folders" branch here? Are there any plans for merge of this into master?

Sebastian.Buesing’s picture