Can the media module work with files stored on the file system?

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
webchuck's picture

I'm new to the media module, and am trying to extend it to pull a list of images from the file system rather than the database.

Here's my situation:
Imagine a multi-site environment like drupalgardens.com where you may have dozens of unique websites using a shared code base. You'd like to provide a shared image library for all website owners to view and choose images from. For obvious reasons, you don't want to maintain this library at the database level for each site, but rather at the code level just once.

So far, with a few hours invested, I've managed to create a plug-in that displays a list of images from the file system. Pretty cool, and pretty simple so far. But now I realize I'm not sure how the media module works from here. How do I select an image and submit it to the media module? And without an fid, can my image be handled the same as if the user had uploaded their own image?

So I'm stuck, and would be very grateful for any help on where I go from here.

-Chuck

Comments

Views?

tsvenson's picture

Wouldn't the Views support in Media 2.x be just perfect for what your trying to accomplish? Not only can you easily create the lists you need, but you can also take advantage of all the other goodies when it comes to what for example the File Entity module makes available in the form of adding fields to a file.

--
/thomas
T: @tsvenson | S: tsvenson.com

Media (and core) requires the

Dave Reid's picture

Media (and core) requires the files to be managed as records in {file_managed}. There's really not any way of getting around that. There are interesting solutions that allow you to work with 'remote' files like http://drupal.org/project/remote_stream_wrapper. For your use case you'd probably want to make one install the definitive 'media server/master' that stores all the actual files. The tricky part is keeping the files in sync between all the master and all the 'slave' sites.

Senior Drupal Developer for Lullabot | www.davereid.net | @davereid

Dave, thanks for getting back

webchuck's picture

Dave, thanks for getting back on this. I didn't like the idea of syncing files between master/slave sites. I ended up creating a separate module that added a new tab to the media module. The new tab displays an image gallery, pulled from the filesystem. When an image is selected the image URL is then loaded into the form used for adding external images ('web' tab), and is added to the media library through that form. That may not make much sense, but it was a simple solution for the issue.

Share?

nicholasyonko's picture

Can you share that module?

I don't mind sharing the

webchuck's picture

I don't mind sharing the module, with the following understanding:

  • this module was designed for a specific use case, so it may not be very configurable, flexible, etc...
  • I don't have the ability to provide any support for this module. You can post questions here, but I can't guarantee a prompt reply, or any reply at all...

There will be some basic configuration required to make this module work. At the top of the .module file there are a few static variables that define the path to your files directory. You'll need to update these for your server.

You can download the file here:
http://webchuckhosting.com/files/media_static.zip

Appreciated!

nicholasyonko's picture

All caveats understood. Thanks for sharing!

Media

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: