Skip to content
Snippets Groups Projects
Commit 98b1cdc3 authored by catch's avatar catch
Browse files

Issue #1353030 by BTMash, jenlampton, theborg: Added Increase length of "alt"...

Issue #1353030 by BTMash, jenlampton, theborg: Added Increase length of "alt" and "title" text for images.
parent e6a95a81
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -404,7 +404,7 @@ function image_field_widget_process($element, &$form_state, $form) { ...@@ -404,7 +404,7 @@ function image_field_widget_process($element, &$form_state, $form) {
'#default_value' => isset($item['alt']) ? $item['alt'] : '', '#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.'), '#description' => t('This text will be used by screen readers, search engines, or when the image cannot be loaded.'),
// @see http://www.gawds.org/show.php?contentid=28 // @see http://www.gawds.org/show.php?contentid=28
'#maxlength' => 128, '#maxlength' => 512,
'#weight' => -2, '#weight' => -2,
'#access' => (bool) $item['fid'] && $settings['alt_field'], '#access' => (bool) $item['fid'] && $settings['alt_field'],
); );
...@@ -413,7 +413,7 @@ function image_field_widget_process($element, &$form_state, $form) { ...@@ -413,7 +413,7 @@ function image_field_widget_process($element, &$form_state, $form) {
'#title' => t('Title'), '#title' => t('Title'),
'#default_value' => isset($item['title']) ? $item['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.'), '#description' => t('The title is used as a tool tip when the user hovers the mouse over the image.'),
'#maxlength' => 128, '#maxlength' => 1024,
'#weight' => -1, '#weight' => -1,
'#access' => (bool) $item['fid'] && $settings['title_field'], '#access' => (bool) $item['fid'] && $settings['title_field'],
); );
......
...@@ -118,13 +118,13 @@ function image_field_schema($field) { ...@@ -118,13 +118,13 @@ function image_field_schema($field) {
'alt' => array( 'alt' => array(
'description' => "Alternative image text, for the image's 'alt' attribute.", 'description' => "Alternative image text, for the image's 'alt' attribute.",
'type' => 'varchar', 'type' => 'varchar',
'length' => 128, 'length' => 512,
'not null' => FALSE, 'not null' => FALSE,
), ),
'title' => array( 'title' => array(
'description' => "Image title text, for the image's 'title' attribute.", 'description' => "Image title text, for the image's 'title' attribute.",
'type' => 'varchar', 'type' => 'varchar',
'length' => 128, 'length' => 1024,
'not null' => FALSE, 'not null' => FALSE,
), ),
'width' => array( 'width' => array(
......
...@@ -746,7 +746,10 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase { ...@@ -746,7 +746,10 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase {
$widget_settings = array( $widget_settings = array(
'preview_image_style' => 'medium', 'preview_image_style' => 'medium',
); );
$this->createImageField($field_name, 'article', array(), $instance_settings, $widget_settings); $field = $this->createImageField($field_name, 'article', array(), $instance_settings, $widget_settings);
$field['deleted'] = 0;
$table = _field_sql_storage_tablename($field);
$schema = drupal_get_schema($table, TRUE);
$instance = field_info_instance('node', $field_name, 'article'); $instance = field_info_instance('node', $field_name, 'article');
$this->drupalGet('node/add/article'); $this->drupalGet('node/add/article');
...@@ -789,18 +792,17 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase { ...@@ -789,18 +792,17 @@ class ImageFieldDisplayTestCase extends ImageFieldTestCase {
// Verify that alt/title longer than allowed results in a validation error. // Verify that alt/title longer than allowed results in a validation error.
$test_size = 2000; $test_size = 2000;
$max_size = 128;
$edit = array( $edit = array(
$field_name . '[' . LANGUAGE_NONE . '][0][alt]' => $this->randomName($test_size), $field_name . '[' . LANGUAGE_NONE . '][0][alt]' => $this->randomName($test_size),
$field_name . '[' . LANGUAGE_NONE . '][0][title]' => $this->randomName($test_size), $field_name . '[' . LANGUAGE_NONE . '][0][title]' => $this->randomName($test_size),
); );
$this->drupalPost('node/' . $nid . '/edit', $edit, t('Save')); $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( $this->assertRaw(t('Alternate text cannot be longer than %max characters but is currently %length characters long.', array(
'%max' => $max_size, '%max' => $schema['fields'][$field_name .'_alt']['length'],
'%length' => $test_size, '%length' => $test_size,
))); )));
$this->assertRaw(t('Title cannot be longer than %max characters but is currently %length characters long.', array( $this->assertRaw(t('Title cannot be longer than %max characters but is currently %length characters long.', array(
'%max' => $max_size, '%max' => $schema['fields'][$field_name .'_title']['length'],
'%length' => $test_size, '%length' => $test_size,
))); )));
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment