diff --git a/includes/media.fields.inc b/includes/media.fields.inc
index 25317d4..d176b4a 100644
--- a/includes/media.fields.inc
+++ b/includes/media.fields.inc
@@ -153,7 +153,6 @@ function media_field_widget_form(&$form, &$form_state, $field, $instance, $langc
// @todo This should be a fieldset, but throws a warning about
// element_children.
'#type' => 'media',
- '#collapsed' => TRUE,
'#default_value' => $current_value,
'#required' => $instance['required'],
'#media_options' => array(
@@ -169,21 +168,58 @@ function media_field_widget_form(&$form, &$form_state, $field, $instance, $langc
),
);
+ $fields = array();
if ($field['type'] == 'file') {
- $element['display'] = array(
+ $fields['display'] = array(
'#type' => 'value',
'#value' => 1,
);
+
+ // Add the description field if enabled.
+ if (!empty($field_settings['description_field'])) {
+ $fields['description'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Description'),
+ '#value' => isset($current_value['description']) ? $current_value['description'] : '',
+ '#type' => variable_get('file_description_type', 'textfield'),
+ '#maxlength' => variable_get('file_description_length', 128),
+ '#description' => t('The description may be used as the label of the link to the file.'),
+ );
+ }
}
// Add image field specific validators.
if ($field['type'] == 'image') {
if ($field_settings['min_resolution'] || $field_settings['max_resolution']) {
- $element['#media_options']['global']['min_resolution'] = $field_settings['min_resolution'];
- $element['#media_options']['global']['max_resolution'] = $field_settings['max_resolution'];
+ $fields['media']['#media_options']['global']['min_resolution'] = $field_settings['min_resolution'];
+ $fields['media']['#media_options']['global']['max_resolution'] = $field_settings['max_resolution'];
}
+
+ // Add the additional alt and title fields.
+ $fields['alt'] = array(
+ '#title' => t('Alternate text'),
+ '#type' => 'textfield',
+ '#default_value' => isset($current_value['alt']) ? $current_value['alt'] : '',
+ '#description' => t('This text will be used by screen readers, search engines, or when the image cannot be loaded.
+ (Notice: this field is not fetched on -all- formatters yet. For example: If the Rendered file formatter will be used, this field is not available at the moment.)'),
+ '#maxlength' => variable_get('image_alt_length', 80),
+ '#weight' => 1,
+ '#access' => $field_settings['alt_field'],
+ );
+ $fields['title'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Title'),
+ '#default_value' => isset($current_value['title']) ? $current_value['title'] : '',
+ '#description' => t('The title is used as a tool tip when the user hovers the mouse over the image.
+ (Notice: this field is not fetched on -all- formatters yet. For example: If the Rendered file formatter will be used, this field is not available at the moment.)'),
+ '#maxlength' => variable_get('image_title_length', 500),
+ '#weight' => 2,
+ '#access' => $field_settings['title_field'],
+ );
}
+ $element += $fields;
+
return $element;
}
diff --git a/media.module b/media.module
index 9df1f43..b1d543d 100644
--- a/media.module
+++ b/media.module
@@ -464,15 +464,12 @@ function media_form_field_ui_field_edit_form_alter(&$form, &$form_state) {
if ($form['#field']['type'] == 'file' && $form['instance']['widget']['type']['#value'] == 'media_generic') {
$form['field']['settings']['display_field']['#access'] = FALSE;
$form['field']['settings']['display_default']['#access'] = FALSE;
- $form['instance']['settings']['description_field']['#access'] = FALSE;
$form['instance']['settings']['file_extensions']['#title'] = t('Allowed file extensions for uploaded files');
$form['instance']['settings']['file_extensions']['#maxlength'] = 255;
}
// On image fields using the media widget we remove the alt/title fields.
if ($form['#field']['type'] == 'image' && $form['instance']['widget']['type']['#value'] == 'media_generic') {
- $form['instance']['settings']['alt_field']['#access'] = FALSE;
- $form['instance']['settings']['title_field']['#access'] = FALSE;
$form['instance']['settings']['file_extensions']['#title'] = t('Allowed file extensions for uploaded files');
// Do not increase maxlength of file extensions for image fields, since
// presumably they will not need a long list of extensions.
@@ -877,15 +874,6 @@ function media_element_process(&$element, &$form_state, $form) {
// Set some default element properties.
$element['#file'] = $file;
- $element['title'] = array(
- '#type' => 'item',
- '#title' => $element['#title'],
- '#markup' => '',
- '#description' => $element['#description'],
- '#required' => $element['#required'],
- '#weight' => -100,
- );
-
// @todo This should load from the JS in case of a failed form submission.
$element['preview'] = array(
'#prefix' => '