A Introduction to the Drupal 7 Media Module

tutuploadsmedia_1329323257702.png

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.

Author

  • Steve Burge

    Steve is the founder of OSTraining. Originally from the UK, he now lives in Sarasota in the USA. Steve's work straddles the line between teaching and web development.

    View all posts
0 0 votes
Article Rating
Subscribe
Notify of
guest

11 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Grigory Naumovets
Grigory Naumovets
12 years ago

Thank you Steve, it’s a good intro.

Just a couple of days ago, I was making a presentation about Drupal 7 Media module, too; if anybody is interested, it’s available via SlideShare:

[url][url=http://www.slideshare.net/G_N/drupal-7-media-modules]http://www.slideshare.net/G…[/url][/url]

Nigel Heinsius
Nigel Heinsius
12 years ago

Is it possible to control access to the media that gets uploaded to the media library? For example, I would like one role type to see certain files and another role type to see others. If I have thousands of images I would like to display only certain ones to specific roles.

ReggieW
ReggieW
12 years ago

Thanks for the tutorial and cutting to the chase. The multimedia asset field is deprecated in the latest releases of Media. Use core file field instead. Also, I find that the MediaFront Module works well with the Media module. The Media Module primarily provides organization and storage. MediaFront provides for flexible presentation of all media types.

respace
respace
11 years ago

Hello!

Thanks for this article. It gives a really good introduction to newbies.

nathan
nathan
11 years ago

Hi,great article, question about choice ”Multimedia asset“, I can’t find it in field manager part. only have file can be choice, any suggestion about this? I use last dev version for media modules, how do you setting to get ”Multimedia asset“? please help thanks.

Guest
Guest
11 years ago

Hi,thanks for help, i change to last version for media module, but also get strange, can you tell me where can find this settings, for media? “As you choose the settings, make sure to check both the Video and youtube boxes.” i check couple times can’t find it. thanks

wreckage
11 years ago

Great overview. Thank-you.

I have a couple of questions, though.

1) How do I integrate the Plupload module for multiple image uploads, and can I only do this for one specific content type, or can I just upload x number of images for later use by content types later?

2) Can I upload images directly into the folders I have created with Media on my web host’s server and expect to see them in the Media library?

3) How to I position images within text blocks in a content type? What module(s) do I need for this?

Thank-you for any assistance.

eh
eh
9 years ago

As of Mar 30th, 2015, “Multimedia asset” field is deprecated. Anyone in OSTraining knows what the new way is or can update this training please? Thanks.

Kunal Joshi
Kunal Joshi
7 years ago

in this filed how to add alter text like image field

11
0
Would love your thoughts, please comment.x
()
x