Drupal Media, Now with Fieldable Entities!

aaron's picture

If you haven't looked recently, there's been some huge progress recently for Drupal's Media module. Jacob Singh from Acquia has jumped on board, paving the way for fieldable entities! This allows Media asset objects to be a first class Drupal citizen, alongside Nodes, Users, Taxonomy, and Comments. (Hopefully in core for Drupal 8!) Also, Dipen Chaudhary has been hard at work providing WYSIWYG support!

Media as an Fieldable Entity

The Tutorial

If you want to give it a spin, you'll need to install Drupal 7, Media, Styles, and optionally Media: YouTube. Then enable the packaged Media Core, Drupal File Module Bridge, and all the modules in the Styles section (Styles, File Styles, and Styles UI). Important: You'll also need to disable the Overlay module (built into core); they don't play well together yet.

Next go to the Media Types overview listing page at /admin/structure/media. You'll see several pre-defined types, including Video, Audio, Image, and Other. (These are not set in stone; chime in with your own suggestions!) Down the road you'll be able to add new types as well with a UI.

Click 'Manage Fields' next to Image, taking you to /admin/structure/media/manage/image/fields. This screen allows you to add new fields to Image type media. For instance, you might have a textfield for Photo Source, or a checkbox to demark whether an image is a photograph of an animal.

Now click the 'Manage Display' tab. The top 'File' field stores the actual file/stream info for this asset. There are four display modes, for 'Preview', 'Small', 'Large', and 'Original'. By default, all four modes will display a 'Generic file', which will simply be a link to the original file. You can change these with the selectors. For instance, you might want the 'Preview' mode to display a 'File Style: thumbnail', and the 'Large' mode to display 'File Style: large'. (More on styles in a bit.)

Now we'll add a Media field to our built-in Article content type. Go to the Content types overview page at /admin/structure/types, and click the 'Manage fields' link for the Article type, which brings you to /admin/structure/types/manage/article/fields. Add a new field, called 'Media', by selecting the 'Multimedia asset' field type from the appropriate selector. (Make sure to fill in both the name and label.)

Save the resulting Field settings without changing anything. On the next screen, you'll also see Allowed Media types, which selects 'Image' by default and 'Public files' and 'Private files' URI schemes. Leave these alone for now.

Go to the Media content listing page, by clicking on the very top 'Content' link and clicking on the 'Media' tab (which brings you to /admin/content/media/list). Then click on the 'Upload new files' link and upload an image. (Note there's currently a bug if you have this installed in a subdirectory, leading to a 404. No big deal, just navigate back and hit the edit link of the resulting media file.)

This should bring you to the new media file asset's edit screen, where you can add metadata information, checkboxes, or whatever, based on the Media type fields you entered earlier.

Now add some content to the site, by clicking on the 'Add content' link that is displayed at the top of every page, and clicking next on 'Article', bringing you to /node/add/article. Make up a title, then scroll down to near the bottom, where you'll currently see a textfield with the number 0, a link reading 'Select media', and some 'Debug information'. (That will eventually be made more user friendly.)

For now, click on the 'Select media' link. If all goes well, you'll see a popup browser listing your newly uploaded file from earlier. Click the thumbnail for your image and hit OK; it should now appear on the node form.

Save your node, and you'll see the new media!

Other stuff to play with: go to the File styles configuration page, by clicking on the top Configuration link, and finding File styles in the Media section below. (That's at /admin/config/media/file-styles). You'll see the pre-defined file styles here, which you can edit (don't edit 'square_thumbnail' for now; there's an error on that preset page). Ultimately, you'll actually be able to do some fancy stuff like actually add new presets, save them, add autoplay to YouTube, display images with links to larger files or to the original contextual node, etc. For now, all you can do is flip through the vertical tabs and see the fancy previews. It's just a teaser for now.

Expect much in the coming weeks; the first Alpha is planned for about January 21, 2010!

(Cross-posted at AaronWinborn.com.)


This looks pretty sweet. I

Garrett Albright's picture

This looks pretty sweet. I think you guys just redefined the answer to the old "How do I add a picture to a post?" question as far as D7 is concerned. To everyone involved, thanks for your work.

I'm looking forward to your

Roi Danton's picture

I'm looking forward to your alpha, so I can use your entity in my filter module that allows inlining and referencing the files in textfields/WYSIWYG.

AthenaAdam's picture

I am surprised to see the enthusiasm for a new media module of the same people who have not yet managed to make the already existing media module, media mover, work for drupal 6. And they are talking about drupal 7. lol .. what an irony! The whole set of media mover modules, xspf playlist, ffmpeg wrapper, flvmediaplayer, and media mover, is a veritable nightmare for users -- buggy and unreliable and throwing innumerable errors. Against this scenario it wont be wrong to doubt about the capacity of a new module .. the so called media module. I sincerely wish that developers and helpers first make this nice idea, called media mover, executable at the earliest.

I am surprised to see the

Garrett Albright's picture

I am surprised to see the enthusiasm for a new media module of the same people who have not yet managed to make the already existing media module, media mover, work for drupal 6.

Here's the committers for Media, and here's the committers for Media Mover. With the exception of Singh, who hasn't committed to the latter in over a year, there's no overlap there. I think you're venting your frustration at the wrong people.

To the extent that I can, not

aaron's picture

To the extent that I can, not being involved in its development, I apologize on the behalf of the Media Mover and the other listed modules for any issues you've had with them. From my experiences with those modules, I know that the learning curve is steep, and it can be particularly difficult to set up in the best of circumstances, let alone when you're customizing it for new possibilities. At the same time, I still believe they are generally the most flexible solutions in their realm available for Drupal 6. The best place to look for support with those modules would be in their respective issue queues.

However, I should point out that the Media module is an entirely different beast, which is harnessing the new file and stream handling capabilities of Drupal 7 (and looking forward out to Drupal 8 with its provided fieldable entities). It provides an API integrating the unified file storage of Drupal 7 with an editor's file browser (integrated with WYSIWYG nonetheless).

Aaron Winborn

Aaron Winborn
Drupal Multimedia (my book, available now!)

I welcome help

arthurf's picture


I have a full time job which does not allow me to be a full time drupal developer. Though I've been a drupal developer for a bunch of years and sometimes my job and my role as a developer overlap it is not often the case. I built media mover and have deployed in production environments on a number of large and small sites alike. I help people all the time get it running on their sites- I can't even keep up with the number of support requests I get on a weekly basis. Sorry it doesn't work for you. I welcome constructive criticism, bug reports and help - both in code and helping other people implement the module.

It's sad to me that the impulse of frustration is vitriolic rather than helpful- what makes the drupal community great is that it has functioned as a community, not as a place to take out frustrations on people who try to provide functionality for the benefit of all. I would also note that despite your doubt (and indeed, misuse of the term irony) belies the history and spirit of free and open source software- much less drupal.

Please join in the development effort - not only are more people welcome, they are needed- for precisely the reasons why you seem so frustrated.

@ arthurf Well put! And

ronliskey's picture

@ arthurf

Well put! And thanks for your contributions. The real world can be a frustrating place as it rarely conforms to our personal adolescent fantasies, but the many billions who over time have worked to make things a little better are the unsung heroes of our world. I guess most don't need to have a song written from them. They already hear the music. :-)

Think hard, work smart, play often...

True! But some appreciation

vonn.new's picture

True! But some appreciation always helps too.

I, for one, am greatly indebted to those of you who work to create the modules I use, fix bugs, add features, answer questions and so on. You are a great example of people who work in a cooperative model that serves themselves and others at the same time.

I'm working on getting my programming skills to the point where I feel like I can contribute to this open source community also. So far, I've only been able to contribute by asking questions that hopefully others have too and occasionally posting a solution I've found to some issue. I can see myself helping with testing and documentation as I'm able.

Yay to the Committers!

Use advantage of open source development

Roi Danton's picture

The whole set of media mover modules, xspf playlist, ffmpeg wrapper, flvmediaplayer, and media mover, is a veritable nightmare for users -- buggy and unreliable and throwing innumerable errors.

You are right. So use the advantage of Open Source, step in, read the code, read the docs, read the issue queues (and foremost try to understand) and then help to make this nightmare go away. :)

Most people don't contribute

TapSkill's picture

Most people don't contribute at all. They just expect the module creators to continually work for free. This should change.

help with site management

roweena's picture

Hi everyone: This is my first time ever doing a blog (i guess). As that shows I am not a computer 'with it' person. And don't even know if this is the correct place for this. If not, can someone re-direct me tx. I need to find out how to creat folders in the site management aera and then how to move files into the folders. I am partially maintaining our site and can only access the mgmt aera when I have to link something. I would upload the file that needs linking. There are the files I would like to put into various folders for easy access and search. Thanks for all your help. r.

Roweena; This isn't a blog;

Garrett Albright's picture


This isn't a blog; instead, you've posted a reply to a thread - a topic of conversation - about web sites built with the Drupal software. Your comment is unrelated to the subject of this thread, and it sounds like your web site may not be using Drupal at all, so those of us reading this thread probably can't help you very well.

For help with your site, I suggest you contact others who have worked on the site (as you say you are only partially managing it), or possibly the company that is hosting your site. They can probably help you a lot better than we can.

Got it to work, but...

muranod's picture

... it showed fine when I went to "Media" to see the file I uploaded and tagged, but I couldn't not get it to go into a content type. "Only files of type .txt are allowed." Don't see any way to change that.

It is really frustrating trying to do what should be something simple, like attaching a credit and caption to an image.

I'm going to try again with the dev versions of media and file entity and will report back.

Got it to work -- followup

muranod's picture

Had to set the allowed file types in the content type to jpg, jpeg, png.

So, it works, BUT does not display the caption, only the credit. (I added a field for a credit and one for a caption).

Worst case scenario is that I can have at least a caption tied to the image and add the credit there, though I would like two separate fields. Any suggestions are welcome. I'll try again tomorrow.

sorry - duplicate post

muranod's picture

(clicked save twice)

It's working now! (but with one issue)

muranod's picture

It's working now. Don't forget to set the field labels to "hidden" in both the image/file setup and the content type.

Also, I can only get the caption text to stay if I set it to plain text. It will work if I set it to html or full html, but when I go back to edit it, the text disappears.

Thanks for posting these directions here!

let users fill in metadata information

Jc Denton's picture


That post is very clear and helpful. Thanks for that!

I would like to know if i can permit my users to complete the fields i created for the image file type.
Now i can see them if i navigate to "admin/content/media" and select an image. But i am the administrator..so can users have access to the custom fields i created and complete them when they upload their images?

thank you in advance.

rinkiprasad's picture

Please sugget how we can attach the comment with image

File API

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week