diff --git a/core/modules/image/image.field.inc b/core/modules/image/image.field.inc index 2e9918932fa0f780ea7aebc3d838fd31aa45efbb..7a38df4aff70bfca97bf55c2692e1b730a450361 100644 --- a/core/modules/image/image.field.inc +++ b/core/modules/image/image.field.inc @@ -403,7 +403,8 @@ function image_field_widget_process($element, &$form_state, $form) { '#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.'), - '#maxlength' => variable_get('image_alt_length', 80), // See http://www.gawds.org/show.php?contentid=28. + // @see http://www.gawds.org/show.php?contentid=28 + '#maxlength' => 128, '#weight' => -2, '#access' => (bool) $item['fid'] && $settings['alt_field'], ); @@ -412,7 +413,7 @@ function image_field_widget_process($element, &$form_state, $form) { '#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.'), - '#maxlength' => variable_get('image_title_length', 500), + '#maxlength' => 128, '#weight' => -1, '#access' => (bool) $item['fid'] && $settings['title_field'], ); diff --git a/core/modules/image/image.test b/core/modules/image/image.test index 444c2ed2e10d00dfa104d86dcf9af302295ef3f8..6fa015e8aec6f73d10e77b01f8e8539fb9d0287e 100644 --- a/core/modules/image/image.test +++ b/core/modules/image/image.test @@ -786,6 +786,23 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase { $this->drupalPost('node/' . $nid . '/edit', $edit, t('Save')); $default_output = theme('image', $image_info); $this->assertRaw($default_output, t('Image displayed using user supplied alt and title attributes.')); + + // Verify that alt/title longer than allowed results in a validation error. + $test_size = 2000; + $max_size = 128; + $edit = array( + $field_name . '[' . LANGUAGE_NONE . '][0][alt]' => $this->randomName($test_size), + $field_name . '[' . LANGUAGE_NONE . '][0][title]' => $this->randomName($test_size), + ); + $this->drupalPost('node/' . $nid . '/edit', $edit, t('Save')); + $this->assertRaw(t('Alternate text cannot be longer than %max characters but is currently %length characters long.', array( + '%max' => $max_size, + '%length' => $test_size, + ))); + $this->assertRaw(t('Title cannot be longer than %max characters but is currently %length characters long.', array( + '%max' => $max_size, + '%length' => $test_size, + ))); } /**