Commit cf5e1a67 authored by torotil's avatar torotil Committed by joseph.olstad

Issue #1343022 by torotil, greenSkin, diqidoq, thekevinday, cbiggins,...

Issue #1343022 by torotil, greenSkin, diqidoq, thekevinday, cbiggins, jwilson3, MacMladen, sirko_el, l0ke, seorusus: Adding alt and title attributes from fields to image markup
parent d10355f1
......@@ -271,6 +271,32 @@ function media_field_widget_process($element, &$form_state, $form) {
);
}
// Add the alt field if enabled.
if (!empty($instance['settings']['alt_field']) && $item['fid']) {
$element['alt'] = array(
'#title' => t('Alternate text'),
'#type' => 'textfield',
'#default_value' => isset($item['alt']) ? $item['alt'] : '',
'#description' => t('This text will be used by screen readers, search engines, or when the image cannot be loaded.<br />
<em>(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.)</em>'),
'#maxlength' => variable_get('image_alt_length', 80),
'#weight' => 1,
);
}
// Add the title field if enabled.
if (!empty($instance['settings']['title_field']) && $item['fid']) {
$element['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => isset($item['title']) ? $item['title'] : '',
'#description' => t('The title is used as a tool tip when the user hovers the mouse over the image.<br />
<em>(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.)</em>'),
'#maxlength' => variable_get('image_title_length', 500),
'#weight' => 2,
);
}
// Adjust the Ajax settings so that on upload and remove of any individual
// file, the entire group of file fields is updated together.
if ($field['cardinality'] != 1) {
......
......@@ -362,10 +362,7 @@ function media_form_field_ui_field_edit_form_alter(&$form, &$form_state) {
$form['instance']['settings']['file_extensions']['#required'] = FALSE;
}
// 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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment