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?
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
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
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?
Can you share that module?
I don't mind sharing the
I don't mind sharing the module, with the following understanding:
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!
All caveats understood. Thanks for sharing!