function _media_browser_plus_ensure_field_folder in Media Browser Plus 7
Same name and namespace in other branches
- 7.2 media_browser_plus.install \_media_browser_plus_ensure_field_folder()
Make sure the field_tags field exists and is of the right type.
1 call to _media_browser_plus_ensure_field_folder()
- media_browser_plus_install in ./
media_browser_plus.install - Implements hook_install().
File
- ./
media_browser_plus.install, line 64 - Install file for media_browser_plus.
Code
function _media_browser_plus_ensure_field_folder() {
// Make sure the 'tags' vocabulary exists.
$vocabulary = taxonomy_vocabulary_machine_name_load('media_folders');
if (!$vocabulary) {
$description = st('Use media folders to organize your media');
$help = st('Enter a concise name for the media folder');
$vocabulary = (object) array(
'name' => 'Media Folders',
'description' => $description,
'machine_name' => 'media_folders',
'hierarchy' => 1,
'help' => $help,
);
taxonomy_vocabulary_save($vocabulary);
}
$field = array(
'field_name' => 'field_folder',
'label' => st('Media Folder'),
'type' => 'taxonomy_term_reference',
// Media file can only be in one folder at a time.
'cardinality' => 1,
'entity_type' => 'file',
'bundle' => 'image',
'required' => TRUE,
'settings' => array(
'allowed_values' => array(
array(
'vocabulary' => $vocabulary->machine_name,
'parent' => 0,
),
),
),
);
_media_browser_plus_ensure_field($field);
// Ensure instance for each media bundle.
foreach (array_keys(media_type_get_types()) as $bundle) {
$field['bundle'] = $bundle;
_media_browser_plus_ensure_instance($field);
}
}