Hi,

We're currently building a large article+photo database, which amongst others include 5-10,000 images. This has presented us with a interesting problem: Finding the right image when browsing the media library.

On each photo, we have three extra fields, photographer, title and description which in our old system, was all searchable. So when the journalists wanted to insert a photo in a article, they'd press the "browse library"-button, search for a keyword or two, and pick a suitable photo as a illustration for the article.

There is no way to recreate this in Media.

So what I'm proposing is some way of adding in search capabilities in the Media library. I don't know how hard it is to get the search module to add in non-node entities.
This search-functionality could have uses outside the "choose media"-popup, as it would allow someone to create ie a photo-sharing site via Media where users can search for other users photos via the content of the fields attached to the image-bundle.

Anyways, I just wanted to get the discussion started. Would anybody else find this useful?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

JacobSingh’s picture

Project: D7 Media » Media Browser Plus

Yes! Absolutely. check out the Media browser plus project (I moved this issue). We're trying to keep the media module light, and allow addons through other mods. This also helps build a good api. I'm not sure if search belongs in the general media_browser_plus, but it could start there as a sub module and if it takes wings get its own shingle I suppose.

fangel’s picture

Cool, didn't know about the Media Browser Plus module. I'll let the issue sit here for a while, and then if nobody with actual knowledge of the browser api tries to implement this, I might give it a shot.

Sebastian.Buesing’s picture

Hi,

its on my to-do list, but has a low priority for now, so can't promise any dates or anything. There is already a filter, but its rather static and in due time this should be replace with a more convenient one which allows all (in the settings checked) fields to be included in it.

Be sure to to poke me every now and then for status updates ;)

Greetings,
Sebastian

fangel’s picture

We (as in, the company I work for) wouldn't mind joining in, and contribute patches or however else we could help. As mentioned, we already have a large database of photos that we want to use.. What are your immediate thoughts on how to implement the search?

We've looked into using Search API (http://drupal.org/project/search_api) to maintain the index, and search it. It looks like a decent way to get a separate index for the entities, so it wouldn't accidentally clutter the main site search with Media entities..

Sebastian.Buesing’s picture

Hi,

I'll have a look at the Search API this evening and come back to you on this. Some help is of course very welcome :).

Greetings,
Sebastian

Sebastian.Buesing’s picture

Hi,

I have attached a development version (no patch yet) of my latest version of the media_browser_plus module.
This version does include a new Library which uses the same code than the grid view and therefore looks pretty much the same. HOWEVER this feature does not yet work because I need some help on how to pass the items in the "Media Basket" to the next form as it is done in the current library. I tried to understand how the media module does it but I couldn't quite understand it yet.

There are also some other new cool features in this version, but I'd appreciate it if for now we can focus on getting this part done. If I am not mistaken this does only require a skilled Javascript Developer to alter the media_browser_plus.library.js file. Everything else should already be there.

Once this setback is out of the way we can have a look at adding some filtering/search to the new Library.

Greetings,
Sebastian

P.S.: I added some screenshots as an incentive to test this version :-)

fangel’s picture

Hi Seb.
Did you post this comment in the wrong issue? I fail to see how it's connected to searching.. It does however look really nice :)

Sebastian.Buesing’s picture

Hi,

It is connected to searching because I wanted to use this UI to allow the actual searching and you might agree that you can already (with folders and their pages) find/search an image faster than with the regular library.

fangel’s picture

I agree that it's indeed easier to find images when you have a folder-structure. However:

But when I say "search" I mean "have a textfield in which users can enter a search-term, and then get a list of results", not "have some way of manually organizing X images in Y folders which you can then browse, and then find the one you want".

In our existing database we already have the option of organizing things in folders. No one uses it because it's much more convenient to just give it a title and a description and then have a fulltext search option though those fields than it is to also specify a folder and then when you want find it, remember which folder you placed it in and browse your way to it, only to have that folder contain hundreds of files..

And if you would prefer a use-case example:
Say you have a image database consisting of amongst others, 1,000 portraits of CEOs (which shouldn't be a hard image database to compile; think of Techcrunchs). If I want to find Steve Jobs, I want to be able to enter "Steve Jobs" in a search-field and get 1 (perhaps 3) result(s), not browse to "Portraits / CEOs / Tech", and then browse through the 237 pictures of Tech company CEOs to find mr. Jobs..

tazzydemon’s picture

Title: Search option when browsing library » Real folders in Filesystem with Folderised Media_browser_plus

Apologies for this message. I cannot delete this post. I did not realise I was hijacking the thread and have reposted.

Julian

Sebastian.Buesing’s picture

Title: Real folders in Filesystem with Folderised Media_browser_plus » Search option when browsing library

renamed it back to old issue name.

fangel’s picture

Sebastian, (in case you missed it because of the "derailing") - do you see my point in having fulltext searching besides folder-categorization?

Sebastian.Buesing’s picture

Hi fangel,

if you want to speed up things with the search and I'm getting a feeling you do :-) than why don't you go into more detail how you would want the search to look like and behave. For instance should there only be one textfield and should that entry search through all fields...etc.
That way when I actually have time to start working on this again I will get it done much faster.

fangel’s picture

FileSize
209.95 KB

Hi,
You are correct, I would love to have it done soon :-). Actually, I might give it a stab and try and create a prototype myself. I've attached a mock-up of how a search-field could be added to the existing browser-plus interface.

Basically, my thoughts would be to create a new (separate) Search API index, and have all fields of all media entities added to this index. Possibly some sort of checkbox-interface where you could chose which fields to include.
I'm not thinking of having any clever sort of search (e.g. "items tagged with this taxonomy term"), only full text searching across text (or convertible-to-text) fields.

So enter text, press search, the results come up in the browser with paging etc.. Very basic use-flow, not so simple implementation :-)

PS, perhaps loading all media-entities on module-install to tag them with the root-folder isn't the best idea. I ran out of memory, because I have 5k entities. Perhaps it's possible to use the batch-api to do something clever..

Sebastian.Buesing’s picture


PS, perhaps loading all media-entities on module-install to tag them with the root-folder isn't the best idea. I ran out of memory, because I have 5k entities. Perhaps it's possible to use the batch-api to do something clever..

Latest version now performs a batch on hook_enable(). Works fine with a thousand entities ;-)

mstrom81’s picture

Hi there,

I'm new to Drupal and the Media module, and I'm interested in doing something similar to what fangel is.

Right now it seems that the Media library pulls back all items, most recent first. I'm unable to find where in the code it's querying the db. Can anyone please point me in the right direction?

Thanks!

dmsmidt’s picture

sub

Sebastian.Buesing’s picture

Media Entities are loaded from the DB using "Entity Field Query" right here in this function (media_browser_plus_load_multiple($variables)):

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

Does that help you?

mstrom81’s picture

Yes, that helps! Thanks very much, Sebastian.

mstrom81’s picture

Sebastian,

If I'm trying to add search functionality like fangel mentioned above, should I be working off of your Media Browser Plus code from your github? Or can this happen in the Media module itself?

Do you know if anyone is currently working on search functionality within the Media library?

Thanks!

fangel’s picture

After playing around with Search API, if you add a index on media entities (in my exampled simply called media_index), you can perform a full-text search and return Media entities using the following:

  $query = search_api_query('media_index')->keys('_your_search_string_here_');
  $results = $query->execute();
  $media_ids = array_keys($results['results']);
  $media_entities = media_load_multiple($media_ids);

Knowing this, it should be straight forward to add a new tab to the Media browser with a simple search-field. If you want a better interface / integration into Media Browser Plus etc, it would take a bit more work..

-M

Pocketpain’s picture

Sub!

ParisLiakos’s picture

Subscribing.
I am trying to implement this, but i dont have the best javascript skills around.I have made it to a point but i run onto some problems.
I hope someone implements this

ParisLiakos’s picture

FileSize
243.34 KB

a suggestion attached

this way we wouldnt need the colorbox and that approach would work without any additional work in the node edit page when selecting image from widget.

Also it means far less clicks for the end user

fedik’s picture

maybe better make something like the "tags cloud" on top of a files list?

ParisLiakos’s picture

that could work too.but has two drawbacks.
people with smaller screens wouldn't have space for two rows of thumbnails
and second it wouldnt be very usable with loads of tags

fedik’s picture

ok, then maybe try make "tag cloud" in the collapsed fieldset.
Whay this more liked for me: no need remember what tags someone wrote ;) and find something will be more fast I think

marco_cruz’s picture

Hi
Does this module integrate wiht Media Gallery? I cant see the Media Browser Plus when adding items to a gallery...
Also, it would be nice to have Taxonomy!

Sebastian.Buesing’s picture

Does this module integrate wiht Media Gallery? I cant see the Media Browser Plus when adding items to a gallery...

Sure it does. If you click on "add media" inside a media gallery you'll see it in the tab "Library Plus". At least you should if you are using the dev version (https://github.com/Buesing-Sebastian/Drupal---Media-Browser-Plus).

Also, it would be nice to have Taxonomy!

Can't follow. Would do you mean?

marco_cruz’s picture

After installing Media Browser Plus from github i get the following errors:
"Notice: Trying to get property of non-object in _media_browser_plus_folder_list() (line 1147 of C:\xamp174\htdocs\galeria\sites\all\modules\media_browser_plus\media_browser_plus.module).
Notice: Trying to get property of non-object in media_browser_plus_grid_view_form() (line 1786 of C:\xamp174\htdocs\galeria\sites\all\modules\media_browser_plus\media_browser_plus.module).
Notice: Trying to get property of non-object in _media_browser_plus_folder_list() (line 1147 of C:\xamp174\htdocs\galeria\sites\all\modules\media_browser_plus\media_browser_plus.module)."

Also, I cant see any media files, just the loader's animation...

I'm using: Media 7.x-1.0-beta5, Media Gallery 7.x-1.0-beta6, Plupload integration module 7.x-1.0-beta3

marco_cruz’s picture

Also, it would be nice to have Taxonomy!

Can't follow. Would do you mean?

I mean categorize a bunch of files with multiple categories (using taxonomy), when uploading and when editing mutiple files

Sebastian.Buesing’s picture

Categories will come in 1.0 :

http://drupal.org/node/1300480

As for your error:

Please add:
var_dump($vocabulary);
after each of those:
$vocabulary = taxonomy_vocabulary_machine_name_load('media_folders');
near your errors and show me what you get. I'm assuming your vocabulary is broken or doesn't exist.

Sebastian.Buesing’s picture

Status: Active » Needs review
FileSize
17.32 KB

I have created a patch from the sandbox of slashrsm (http://drupal.org/sandbox/slashrsm/1294592) to add a filter above the "Library Plus". I also did some coding standard improvements and used the multiedit option that is now included inside the media module.

The patch is made against the "github" branch.

heyyo’s picture

Could we use this patch on the last dev version ?

Sebastian.Buesing’s picture

Not yet. It has to updated first ;-)

Sebastian.Buesing’s picture

I reworked the patch. Needs review!

ParisLiakos’s picture

well the patch introduces some whitespace errors, but beyond that functionality seems good..

EDIT: scratch that i am getting some weird crashes cant find out the reason.seems completely random

dmsmidt’s picture

I'm testing two (all kinds of things)
What kind of crashes?

It works (almost) for me.

Would be great if the filters on admin/content/media worked that easy.
Activating on hitting enter would help.
If you clear the field, hit "filter". The fieldset will close (looks strange)

I wanted to test further on usability with a filter set and using different folders, but this error is killing me:
http://drupal.org/node/1355126
Fixed super fast by: rootatwc

Edit:
I think it is easier to unset the filter after hitting continue. Or show more clearly that a filter is being used.
It feels strange that going to admin/content/media is also filtered if you don't reset it.

ParisLiakos’s picture

i got them on chrome 14.got the aww snap page.but cant say more since javascript console seems to crash too.

well got it twice and no more.no matter how much i try cant crash it.so maybe it was a chrome bug?w/e just disregard it unless someone else gets it

dmsmidt’s picture

It works for me on chrome 16.

Some more notes: I would add a option select: filter all folders | filter active folder
Or something enabling searching all folders at once.
When filter all folders is selected the folder tree could be hidden until reset.

dmsmidt’s picture

Seems that the patch removes this line from media_browser_plus.info:
dependencies[] = multiform

ParisLiakos’s picture

indeed..i guess its by accident?

Sebastian.Buesing’s picture

Hi,
it is not. The media module now comes with it's own multiedit form, so we don't need this anymore. ;-)

bisonbleu’s picture

Issue summary: View changes

I know it's been 4 years, but this patch works great when keeping Media 1.x on an existing website is required.

That being said, and with the latest dev (7.x-1.0-beta3+19-dev, dated 2016-02-06), multiform.module is required!