Media Presentation at Drupalcon Chicago

 

by Jacob Singh and Aaron Winborn

Jacob:

Media is a module for Dupal 7. It extends the file management capabilities in core. We take the base ways that you can handle files and added enhancements. It's a framework for handling media meta-data such as authorship or quality information, as well as a consistent user interface for managing files. These are the goals of Media.

Drupal has notoriously bad multimedia handling. Media module has been a long process and in Drupal 7 it's come to fruition, thanks to the Gardens team. Now, we have 2000 sites running Media in the wild, in addition to the 45k Drupal Gardens sites.

  • For Usability, we want to address the needs of editors, not site admins or programmers. In the past, we've also lacked
  • Consistency: to use the same interface for managing files.
  • Extendability: we want to be an API, not an end-to-end solution. There's already a module ecosystem that has sprung up to supplement the capabilities of Media

Demo

  • You can upload images, videos
  • You can paste URLs for youtube or flickr
  • Files themselves can have fields: bits of data that can be attached to them. Wherever you reference that file around the site, the fields can be used.
  • We have a creative commons field for attributions, for example

Right now, several people have built modules that can be used with Media, such as AWS and Vimeo. There's somebody working on OEmbed. Modules did this in the past, such as EMfield, but Media takes it a step further because you can do it anywhere in your site with a consistent interface.

Fields

If you build it, it will have fields. Right now, you have to create an Image node and attach fields to the Image. Fields attached to files in D7 is even better. Media is a secure way to allow people who aren't administrators to contribute media to your site. So now, you can allow people to post images and video in your comments without worrying about your site getting hacked by XSS.

Code

Media is an element; if you add $form['media']=array( to your code, you'll be able to embed a media selector UI into your page. We want to make a situation where Media can be the interface used whenever you want to select a file.

Aaron:

In 2007 I became very interested in working on multimedia; I helped work on the original embedded media field. We used it to get flickr and vimeo and other third party providers into Drupal. Before we had that, the only way to deal with media in a site was through attachments with the upload module, which was in core up until Drupal 7. (You could also embed it directly into your content.)

In Drupal 4.7 and before, you had media as a node, which comes with all the node baggage. You have to deal with performance, memory issues when you load it, and it's not easily used outside the context of a node. To this day, Image and Video and Audio are great namespaces, and become the goto for people outside of Drupal who don't know about CCK.

CCK opened up all kinds of possibilities for content, such as FileField, ImageField, et. al. The downside is that the media was still not accessible outside the context of the node.

We spent a lot of time sprinting and gathered a number of sponsors; we had our first beta in January, right after Drupal 7 was released. It's usable now. We have:

  • Media Youtube
  • Media Flickr
  • Workbench
  • Media Internet
  • Media S3
  • Styles
  • Migrate
  • Rotating Banner
  • Media Gallery
  • Media Webcam
  • Media Browser Plus

Combined with the stream wrappers and File API in core, Media helps support things that should have made it into core, but didn't. We also have this pluggable browser that you can feed stuff into; this frees up developers to work on extensions that we can't even think of right now.

The Roadmap

There's still a lot to do. We want Media to be a file browser to the internet, but first we'd like it to be a file browser to your server. We'd also like:

  • Folders
  • Permissions
  • Views integration
  • Audio support
  • Other file types (pdf, etc)
  • Other third party provider modules

Sprint, Wednesday 1p-2p
Core conversation: Wednesday 5p-6p
Check out #drupal-media and groups.drupal.org/media

What types of permissions exist currently for Media or Media Gallery?

Binary. Either you can add media, or you can't.

FAQ

Is there an upgrade path for Image nodes?

Currently, any files are accessible to Media. Probably the biggest issue is if you're using embedded media field. Justin Randall is working on a script for that. Right now, it's yes and no. It depends on what you need.

Do you envision this for Drupal 8 will replace FileField or will this be an add-on?

FileField is now in core as File. That's anybody's guess. Drupal 8 development is starting officially today. I'd love to talk to other people who are interested.

What about if you have hundreds of thousands of images?

Don't do that right now. [laughter] It's not so bleak. The architecture will scale up, but the interfaces may not. We have some libraries which have a couple thousand, but the file browser is very basic with ajax scrolling. There is a huge patch in the MediaBrowser Plus module which adds folders and other ways to do filtering by tags. That's the direction we want to go. We just need people to put in time. It's not going to be the finder in Mac.

Anything in the future for image layout within a node?

That's already working. It depends on how you're using the module; it allows you to set up a media field which you can display within a node wherever you want. If you're using WYSIWYG you can stick it directly into your content. You can also resize it in the browser with drag-and-drop.

When you embed an image, can you take the caption with it?

It's kind of difficult from a usability perspective. Do you show the user the field? What if they edit the field? It becomes complex on the editing side, but it can be done on the display side without a lot of difficulty.

Can you install more than one gallery, or galleries for different users?

Not for users, because there's no permissions right now, but you can have multiple galleries. You can have multiple collections of galleries.

What about video and conversion?

There is some limited HTML5 support. That's on the todo list, but there's the Media Element module. A lot of developers work on different pieces. Architecturally, the Media module is the GUI interface for the users and a technical interface for the developers. Things like the specific handling of video conversion would be up to other modules, such as Media Mover.

Support for Services module?

Not that we're aware of.

Is it safe to use the module in beta?

I can't answer that. Drupal Gardens has been using it for some time. There are some modules with a release that maybe shouldn't have one, and then there are some modules like Media which are still in beta even though they're stable for many use cases. You have to look at your organization's policies.

What's the status of Views integration?

There is an issue, we're talking about setting up a sprint to do that. Hopefully, very soon. There's been interest in that from the very beginning. I'm hopeful that even by the end of the week we'll have something. It basically works, but there are some limitations and problems.

Is Media 7 only?

Yes. In the beginning, we talked about making it for 5. Then we moved to 6, and then we scrapped all that and put it in 7. We had to pick our battles. If you're stuck in Drupal 6, you want to look at the usage stats as a good indicator. If there are only 20 sites, there probably won't be a good upgrade path. If there are 20,000 sites using it, you're probably safe using that particular module, because other people who will clamor for it and build it. You're safe using EMfield.

What's the separation between the core Media module and add-ons?

That's a matter of architectural principles. It depends on the individual that's working on it, how stable it is, and how universal. You build things, and then you go back and make them good; there are no hard and fast rules. I want Media to handle fieldable entities, and I want it to have a clean browser.

Is the Image library per user or a central repository?

There's no permissions model yet. There's a patch to fix that by Rebecca. It attempts to do some of that. Access is such a pain in the butt.

Did you enjoy this post? Please spread the word.