Drupal 7 Media Module
Share with Others
In this episode we look at the Drupal 7 Media module and how it can be used to manage all different types of media on your Drupal website. If you are looking for a better file management experience on your Drupal site, the Media module may be able to help you out. It is also useful for displaying content from other websites such as audio, images, or video.
In this episode you will learn:
- How the Drupal 7 Media module can be used to manage various types of media files on your Drupal site.
- How to create a Drupal content type with a media file field.
- How to upload a text file using the Drupal Media module
- How to use the library inside the Drupal Media module
- How to download and install the Media: YouTube module for embedding YouTube videos on a Drupal website
- How to configure the YouTube player from within the Drupal Media: YouTube module.
Welcome to another Daily Dose of Drupal this is Episode Number 15. As always I am Shane and today we’re going to be going over the Drupal 7 Media module. Not only that; but we’re also going to look at how it can be used to upload files to your Drupal site using a nice file interface and also how it can be use to embed other … not necessarily files but other different media types from other sources such as a YouTube video. So let’s go ahead and start by jumping onto our test.codekarate.com site and we’re going to download the Drupal 7 Media module.
So I’m going to hop in to the command line and just download the media module and to show you what it looks like I’m going go to the Modules page and scroll down and you’ll see that there are three different Drupal modules that it has File Entity, Media and Media Internet Sources.
One thing you’ll only make sure you need is ctools or Chaos Tools that needs to be installed and enabled. So I’m going to use all three in these examples so I’ll turn all three of these on, hit Save and there it went and I’m going to then start by creating a Content Type.
In this Content Type I’m just going to create call it Media for this example, we’ll leave everything else the same for now and I’ll come into my Media Content type and I’ll go to Manage Fields and the first you’ll need to do is select File as the field type, I’ll just name the field Media and you’re going to want to select the Media File Selector, so I’ll go ahead and click Save on there, we’re going to keep the Upload Destination at Public Files, you can then select the different file extensions for uploading files, select the … if it’s Public or if it can be use for Public or Private, you can set a maximum upload size, select the specific file directory and then of course the Upload Destination which we already set as well as how many values can be uploaded into this field.
I’ll go ahead and click Save and now we will add a Test Media Node. So we’re going to come down here and there’s a Media Field here, we’re going to select Media, that’s going to open up a little dialog window. Here you can see we can upload the file directly from our computer, we can use a URL or embed code from the web however we don’t have any supported providers installed and we’ll go over that in a second or you can grab something from the library which is currently empty.
So I’ll start by uploading just a test file. So uploading just a text file, you can see that it drops in here, you could remove it if you need to or overwrite it, we’ll click Save and now you have a node created called Test Media with this file dropped in. Now if we go to create another node of the Media type and you come in here you can see that now in our library we have this Test Text file so we can reuse it on other media content that we want to create.
The next step we’re going to do is actually look at embedding a YouTube video. In order to do that we’re going to use the Drupal 7 Media YouTube module and this will integrate in with the Media module so we’ll download that, now that’s downloaded we can enable it and of course do this through Drush as well and you can see the versions we’re using; we’re using the 1.2 version of the Drupal Media module, we’re not using the 2.x version which has some new features but we’re … in this example we’re using the more stable 1.2 version, go ahead and save this.
And now when we go into our Content Type and we go into Manage Fields we can …excuse me we want to go back and we’ll actually try to create one just to show you how it looks. So we’ll go into Media, select YouTube video and when we select Media we’re going to go to the web tab and you can see that the YouTube module we installed now creates a listing for YouTube as a supported provider.
So we’re going to hop over to YouTube and grab a video, just going to grab a video here and we will then copy that URL right into the Text field, click Submit and you’ll see we got an error because only the following files are able to be uploaded and that’s an image.
So we’re going to need to go back into our Content Type, go into our file media selector here and we’re going to click Edit and you can see it tells you allow to remote media types. So you can have remote images, remote audio or remote video. So we need remote video, we’re also going to select the URL or URI scheme for YouTube and hit Save and now if we go back we’ll go ahead and just refresh this page and create a new YouTube video, if we come down here and select Media, go to web paste our YouTube link and again hit submit, you can see that it brings the thumbnail in from YouTube, we can hit save and your YouTube video has been link to your content that you created.
Now this of course doesn’t seem very useful because your goal here is probably to actually embed that video. So that’s where we need to go back into the Content Type for Media and we’ll go to Manage Display and so I’m using Generic File, let’s go ahead and select Rendered File for the Media field that we created, if we click Save come back over to our content we just created and refresh, you now have an embedded YouTube video.
The next step is actually changing the look of this YouTube video a little bit and we can do that by coming in to Configuration and we’re going to then set some Drupal configuration options for this video or for the YouTube display, it’s a taking a little bit of time here to load for some reason so we’ll let that spin for a second here but I’m on the Modules page, if you come down here you’ll see that there’s Configure option for the Media module, I’m just going to go ahead and go to that, we can also see it’s in here somewhere but … so you can select your default different Media types here.
But what we really want to do here is we want to come back in the File Entity module here and we want to click on Configure on that module. So what this allows us to do is it actually allows us to do a couple of things; it allows us to change the Audio Display Fields or manage Actual Display of the audio, same with the image and video different types but we’re going to be looking at just the video here; so let’s click on Manage File Display and you can see the Enable Display our YouTube video and YouTube preview image.
We’re going to go to YouTube Video, you can change the width, height, the player theme, we’re going to select Dark here just so we can see how that would look, you can change the Progress Bar, change settings on different controls and just a whole bunch of different options to really customized how the player will look, so we’re going to save that, now we’re going to go to the YouTube video and you can see that now the entire player has been re-themed a little bit and it just changes the look of the player.
So that is all that we have to go over today and we’ll be back again tomorrow with another episode, you can follow me on Twitter @smthomas3, thanks for watching.