Friday, March 30, 2012

A Introduction to the Drupal 7 Media Module




The Media Module is one of the most hyped new modules for Drupal 7. It is often talked about as the best option for handling images, video and audio files in Drupal 7.

However, available information about the Media Module is long on 90 minute conference presentations and short on quick, practical guides. So, in this tutorial we're going to get right to the point. We're going show you how to set up the Media Module, what it does and how to use it to add YouTube videos to your content. Let's go ....



Install the Media Module




Head over to http://drupal.org/project/media and download the Media Module. You will also need the latest version of the CTools module from http://drupal.org/project/ctools.




tutuploadsmedia_1329323257702.png



Understand the Media Module




Go to Structure > Content types > click Manage fields next to a content type.

You'll see that a new field option called "Multimedia asset" is now available.




tutuploadstutuploadsmedia_1329321089490.png



This field type will allow you to upload a variety of file types. Click Save and you can decide that those file types are:




tutuploadstutuploadsmedia_1329321123983.png



If you create a "Multimedia asset" field for you content, the image below shows what it will look like when you go to add content.




tutuploadstutuploadsmedia_1329321160323.png



Click on "Select media" and you can upload new files.




tutuploadstutuploadsmedia_1329321181758.png



Most importantly, you can also browse a Library of all the files that you've uploaded.




tutuploadstutuploadsmedia_1329321446684.png



This Library feature is the real reason for using Media. As explained on the Media FAQ page: http://groups.drupal.org/node/19746

"The Media module provides an engine that can be used to manage files and metadata. Individual Media module plugins, as well as the modules they integrate with, will handle media display."

So the only thing this field can do at the moment is upload files to the library. If you want to actually show the files, you'll need to rely on extra modules. Let's see how that works.

Go to Structure > Content types > click Manage fields next to a content type. If you choose to add a File field you'll now have a Media file selector option.




tutuploadstutuploadsmedia_1329321575868.png



If you choose to add a Image field you'll now have a Media file selector option.




tutuploadstutuploadsmedia_1329321599641.png



Here's what the Image field will look like when you go to add content.




tutuploadstutuploadsmedia_1329321692781.png



You'll be able to browse your new media library and insert an image just as you would do normally.




tutuploadstutuploadsmedia_1329322313974.png



Adding Video to Content via the Media Module




Adding external videos to the Media module relies on the Embedded Media Field module: http://drupal.org/project/emfield.

That module allows you to hook into all sorts of external sites, provided you have the appropriate module. In this example, we'll use YouTube so install this module as well: http://drupal.org/project/media_youtube.

Install and enable both of those modules.




tutuploadsmedia_1329324509632.png



Go to Structure > Content types and add a Multimedia asset field.




tutuploadsmedia_1329324555689.png



As you choose the settings, make sure to check both the Video and youtube boxes.




tutuploadsmedia_1329324583650.png



Save that new field.

There is one important thing you must now do to make sure that the videos display. Click on Manage Display at the top of the page.




tutuploadsmedia_1329328094802.png



Normally settings for the video field would be available but in this case I had to click Save before they appeared. Then you can click the cog on the right-hand side, next to the video field.




tutuploadsmedia_1329327802623.png



Set the File view mode to Small, Large or Original and click Update.




tutuploadsmedia_1329328239375.png



Click Save so that your changes aren't lost.

Now you can go to Add content and use the new video field.




tutuploadsmedia_1329324699175.png



Once you've inserted the YouTube URL and clicked Submit, you should see a video thumbnail as in the image below.




tutuploadsmedia_1329324715341.png



Save the content and your video will be showing on the page.




tutuploadsmedia_1329328419096.png



YouTube is a simple and popular example. If you want to use other sources for video or audio, head to http://drupal.org/project/emfield and you'll see a list of all the options and the modules that they require.

 

A note of caution: Media is under heavy development. There isn't yet a stable version of Media. As of mid-February, there is a Release Candidate 3 but not yet a stable version.



No comments:

Post a Comment