Skip to content

Instantly share code, notes, and snippets.

@nalipaz
Last active August 29, 2015 14:09
Show Gist options
  • Save nalipaz/9402cfe208fa44d8d1f0 to your computer and use it in GitHub Desktop.
Save nalipaz/9402cfe208fa44d8d1f0 to your computer and use it in GitHub Desktop.
How to save a media type for the media module, will save new or update
<?php
$types['video'] = new stdClass();
$types['video']->name = 'video';
$types['video']->label = "Video";
$types['video']->base = TRUE;
$types['video']->type_callback_args = array(
'match_type' => 'all',
'mimetypes' => array('/^video/'),
'extensions' => array('mov', 'mp4', 'avi'),
'streams' => array('public', 'private'),
);
foreach ($types as $name => $type) {
media_type_save($type);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment