Rather than rolling our own custom browser, we should be using Views by default. This allows us to re-use things like AJAX paging, filtering, etc without having to do it ourselves.
There are several very similar inter-connected issues related to the browser and/or Views integration but I wanted this to be a new issue to discuss.
The tricky part of this is that we need a reliable way for the user to be able to 'select' the file from the view. If the View is using field output, we can provide a 'Select in media browser' field that should be a part of the default view. If the view is using entity-based file output, then we can add a 'Output this file to select in media browser' option to the File view row plugin. We could also provide a new 'Media browser' view row plugin that emulates the output currently used in the custom media browser.
| Comment | File | Size | Author |
|---|---|---|---|
| #33 | css_margin-1224766-33.patch | 618 bytes | idflood |
| #33 | css_margin-1224766-33-before.jpg | 82.57 KB | idflood |
| #33 | css_margin-1224766-33-after.jpg | 79.45 KB | idflood |
| #32 | Media_browser_default_view_broken_missing_handler.png | 153.14 KB | finn lewis |
| #26 | 1224766-26-replace_media_browser_library_with_views.patch | 14.71 KB | robeano |
Comments
Comment #1
dave reidComment #2
keesee commented+1. I agree, Dave. It would also allow easier customizations for admins who would like to tweak the browser or allow them to use the multitude of views plugins to change the display.
Comment #3
dave reidComment #4
dave reidHere's the progress I've made 'emulating' the media browser using views. Still needs some work.
Comment #5
entrigan commented@#4, did you possibly forget to add some files before rolling that patch? I cannot find views_plugin_style_media_browse.inc
Comment #6
dave reidYep I did forget it - that's why I had the foresight to leave it as needs work. :)
Comment #7
finn lewisSounds like this is where it's all happening! I'm looking forward to testing a views based media browser.
Comment #8
aaron commentedlooking great! can't wait to review the real patch...
Comment #9
hernani commentedSub
Comment #10
effulgentsia commentedGreat to see some proof of concept here. Before investing too much time in working with the current, crufty, media browser code though, I think we should work on finishing #1139514: Overhaul the media browser code to not use an iframe, and be more understandable, maintainable, and extendable. If we do that right, then swapping in a view for the library tab shouldn't be too painful (though there's always some pain getting all the AJAX to play well together).
Comment #11
dave reidThis won't depend on #1139514: Overhaul the media browser code to not use an iframe, and be more understandable, maintainable, and extendable at all and won't touch media browser code at all.
Comment #12
jean.cedric.t commented@Dave :
You still work on this, i guess, and i need this, the ability to filter media by tags thanks to "Views", and naturally, in no time…
Can I Help you in some manners ? (I am dev)
Comment #13
csevb10 commentedWe needed this exact functionality for another project, so we built it and - for the time being - released it as a separate module. We'd love to help in any way we can to help get this integrated with Media. We're at your disposal for this, and we'll push to get anything done in a timely fashion.
Check out what we have now: http://drupal.org/project/views_media_browser
Let us know what we can do to help with this and if what we have is a reasonable start. If you don't like the direction we've gone - or you can't find a way to have us help you get it into shape for use in Media - we'll leave ours up so people can leverage it in the interim.
Thanks!
--Bill
Comment #14
dave reid.
Comment #15
muriqui commentedsubscribe... this will be awesome.
Comment #16
becw commentedI'm reviewing and updating this patch.
Comment #17
becw commentedHere's a spiffed up version of Dave Reid's patch from #4. I've added a Views display plugin; any view that uses this display plugin will show up as a tab in the media browser. I've also neatened up the style plugin, added comments, and put the views plugins in the media namespace.
This patch is incomplete; it doesn't actually display the contents of 'media browser' views in the media browser. #1289872: Use ctools plugins to provide add-ons to the media browser would require moving or rewriting the display code, so I will just do that first.
Comment #18
becw commentedGah, I didn't attach the file.
Comment #19
robeano commentedI reviewed becw's patch and added some additional changes.
* added a dependency for Views module
* added a default view for the media browser
* support for additional views when exported and added to media/views/
* made a minor fix so views sees the media plugins
Now, the media_default view does display the thumbnails but it does not function like the original Library tab just yet. Additional issues will be created to manage those changes.
Comment #20
arthurf commentedAbstracted the view names and cleaned up somethings. Needs to be implemented with the files in more appropriate directories.
Comment #21
arthurf commentedRolling again
Comment #22
robeano commentedTested successfully!
Woohoo! We've got a Views support and a default view which can replace the original Library tab in the Media Browser.
There is more work to do so that this default view allows for selecting items, paging through view within the browser. Those will be handled in separate issues.
Comment #23
dave reidThe 'break' statements needs to be indented two spaces.
This file doesn't contain any classes - I don't think it needs to be listed here?
The patch also seems to be missing the default views?
Comment #24
robeano commentedFixed changes suggested in #1224766-23: Remove default media browser and replace with a default view including adding the missing default view.
Comment #25
dave reidExtra space and misspelled 'implementation'
Should these files be in includes/ or plugins/ since they're auto-loadable.
I should have pointed out this file is also redundant in .info file.
Comment #26
robeano commentedChanges from comment #25 included. I'd like one more review. This is a big 'un.
Comment #27
dave reidOverall I don't see anything horribly wrong anymore - could use some manual testing?
Comment #28
finn lewisVery excited to see progress on this, so managed to do a quick test before bed.
Patch in #26 applied fine to the git checkout of 7.x2.x branch.
Used 'drush site-install' to set up a fresh site.
Added an image field with media browser widget to the article content type.
Default view shows up on media browser tab ok - but can't seem to select the images, and there is no submit button.
Attempting to expose some filters on the default view does not appear work just yet - the filters are exposed ok - but submitting the exposed filter form renders the site home page in the overlay iframe.
Reading back over the issue, I'm not sure if any of what I tested is meant to work yet - just thought I'd do a quick test and see how far I could get, so I hope this helps and look forward to testing it again in the morrow.
Thanks for all the work so far on this!
Comment #29
mstrelan commentedSame results as #28.
Comment #30
dave reidHad a good chance to review this and found some issues, fixed them myself, and then committed the patch:
1. Fixed the location of the 'cancel' button on the View.
2. Fixed the extra closing div tag in the view template
3. Fixed a PHP strict warning due to the get_row_class() method not using the same parameters as its parent class views_plugin_style.
4. Actually added some filters to the view on File name CONTAINS and File type selection.
5. Enabled AJAX on the view so that it works for paging and auto-submits the filters.
I committed the following patch to 7.x-2.x after extensive testing. AWESOME WORK EVERYONE!
http://drupalcode.org/project/media.git/commit/5663f4d
As follow ups:
1. Fix the way media items are 'selected' to be more like the current browser library.
2. Remove the custom library code and completely replace it with the view.
3. Allow View titles to alter its own tab title: #1292932: Unable to override media browser tab titles from render/view
4. We probably need to address some file organization in the module. We have stuff in includes/ and views/.
5. The media browser needs to filter files that are not using hidden stream wrappers.
6. The media browser needs to filter based on file type or file extensions like it currently does.
Comment #31
dave reidSCREENSHOT!
Comment #32
finn lewisThis is amazing! Fantastic work media sprint people!
I now have the view, with customised exposed filters, and selecting an image completes the expected action of dropping said image into the image field from which the media browser was launched.
Two issues I noticed were:
- When entering text into and exposed filter field, for example the file name, each time you stop typing, the filter is applied to the view (which is nice), but the focus of that form field is lost, so you need to click back into the text field to continue typing.
- The default view appears to have a Broken/missing handler on both the Filter Criteria and Sort Criteria.
Screenshot attached.
I'm sure these are both trivial enough and am looking forward to being able to use the media browser to filter hundreds or thousands of images and files to make reusing images and files a reality in D7.
Thanks again people! :)
Comment #33
idflood commentednice : )
I have some style issue on firefox 6. Here is a patch that changes some margin and also apply a clearfix method to the "float container".
edit: would it be possible to modify a little the view so it can become easily like in http://drupal.org/files/issues/03_grid_view.jpg ?
#865006: Designs for library and wysiwyg
Comment #34
robeano commentedThanks for everyone's hard work on this issue! Please post new issues instead of posting bugs to this issue moving forward.
All outstanding tasks, bugs and features have been moved into their own new issues:
For comment #30:
#1293670: Views Library Needs to Allow Filter by File Type and Extension
#1293668: Views Library Needs to Hide Temporary Files
#1293666: General Code Review and Cleanup for 2.x
#1293658: Fix Item Select in Views Library
#1293660: Remove old media browser library plugin
For comment #32:
#1293676: Views Library Filter Bugs
For comment #33:
#1293680: Views Libary in Firefox 6
#1293692: Update Views Library to Match UX Design Grid View
Comment #35
ZuluWarrior commentedSub
Comment #36
arthurf commentedThis is blocked by: http://drupal.org/node/1293658 We need to make sure that the submit/cancel buttons are functional before we can replace the stock library view.
Comment #38
jp.stacey commentedFor reference, the ticket mentioned by @arthurf in comment #36, which I worried might still be a blocker, is fixed: #1293658: Fix Item Select in Views Library - presumably the tickets @robeano mentions in #34 should get crossed off by automatic formatting as they too get fixed.
Comment #39
ZuluWarrior commentedSo, forgive me for being dense, is this issue resolved now? With the patched mentioned above can I get a views based media file selector?
Does it honour the file upload directory (if supplied) of the media field?
Comment #40
arthurf commentedYes- fix is in the dev branch
Comment #41
jenlamptonLooks like the non-views Library never got removed. Is that part of this issue, or will that be done in #1293660: Remove old media browser library plugin?
Comment #42
dave reidCorrect, we still plan to remove the old tab with #1293660: Remove old media browser library plugin which is blocked by #1293908: Respect file type restrictions in media browser library view.
Comment #43
gmclelland commentedTo address what @finn.lewis said in #32
Might explain why this is happening http://drupal.org/node/1319528#comment-5605672