Community Documentation

Media Types

Last updated January 10, 2012. Created by mradcliffe on May 27, 2011.
Edited by Devin Carlson. Log in to edit this page.

Media types is a bundle for media entities.

You can add a new media type via the media_type_save() function.

<?php
  $type
= new StdClass();
 
$type->name = 'mymediatype';
 
$type->label = 'My Media Type';
 
$type->base = TRUE; // @todo what?
 
$type->type_callback_args = array(
   
'match_type' => 'all', // @todo what?
   
'mimetypes' => array(),  // An array of regex patterns e.g. /^audio/
   
'extensions' => array(), // An array of extensions
   
'streams' => array() // An array of streams @todo what?
 
);

 
$type = media_type_save($type);
?>

Page status

About this page

Drupal version
Drupal 7.x
Audience
Developers and coders

Site Building Guide

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.