function media_form_alter in D7 Media 6
Same name and namespace in other branches
- 8 media.module \media_form_alter()
- 7.4 media.module \media_form_alter()
- 7.2 media.module \media_form_alter()
- 7.3 media.module \media_form_alter()
Implementation of hook_form_alter().
_state _id
Parameters
$form:
File
- ./
media.module, line 63 - Media API
Code
function media_form_alter(&$form, $form_state, $form_id) {
global $user;
// Load content-type settings
if ($form_id == 'node_type_form') {
include_once 'media_settings.inc';
media_settings_content_type($form, $form['#node_type']->type);
}
// Add the media browser on the node add/edit screen.
if (strstr($form_id, 'node_form')) {
// Is the media browser enabled on this node type? Type-specific options override the default.
if (variable_get('media_' . $form['type']['#value'] . '_override', NULL) !== NULL) {
$enabled = variable_get('media_' . $form['type']['#value'] . '_enabled', NULL);
}
else {
$enabled = variable_get('media_global_enabled', TRUE);
}
if ($enabled) {
// Get the fields we need to enable on this module.
$fields = media_active_fields_for_node_type($form['type']['#value']);
// Iterate through each field and add a browser form.
foreach ($fields as $field => $registration_ids) {
// Add the media browser form.
$form[$field]['media'] = media_build_browser_form($form_state, $registration_ids, $form['type']['#value'], $field, $user->uid);
// Add .media and .replace class to the field CSS class attributes.
$form[$field][0]['#attributes'] = array(
'class' => 'media replace',
);
}
}
}
}