function _media_gallery_ensure_media_instances in Media Gallery 7
Same name and namespace in other branches
- 7.2 media_gallery.install \_media_gallery_ensure_media_instances()
Makes sure media entities have the fields media gallery requires.
1 call to _media_gallery_ensure_media_instances()
- media_gallery_install in ./
media_gallery.install - Implements hook_install().
File
- ./
media_gallery.install, line 851 - Install file for media_gallery. Includes field and instance definitions.
Code
function _media_gallery_ensure_media_instances() {
$t = get_t();
$instances = _media_required_instances();
foreach (media_type_get_types() as $bundle => $type) {
foreach ($instances as $instance) {
$instance_copy = $instance;
$instance_copy += array(
'entity_type' => 'file',
'bundle' => $bundle,
);
$label = in_array($bundle, array(
'image',
'audio',
'video',
)) ? $bundle : 'file';
if ($instance_copy['field_name'] == 'field_tags' && !isset($instance_copy['description'])) {
$instance_copy['description'] = $t("Enter a comma-separated list of words to describe your {$label}.");
}
if ($instance_copy['field_name'] == 'field_license') {
$instance_copy['label'] = $t("License settings for this {$label}");
$instance_copy['description'] = $t('Select a <a href="http://creativecommons.org" target="_new">Creative Commons</a> license for others who use this ' . $label . '.');
}
_media_gallery_ensure_instance($instance_copy);
}
}
}