In image/image.field.inc, the ALT and TITLE form input lenths are set to 80 and 500.
However, the Drupal DB tables are set to varchar(128).
This means people can enter 500 chars for a title, but will lose this in the DB. And why shouldn't people be allowed to provide a longer ALT than 80 chars? Why not 128 like the DB?
$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.'),
'#maxlength' => variable_get('image_alt_length', 80), // See http://www.gawds.org/show.php?contentid=28.
'#weight' => -2,
'#access' => (bool) $item['fid'] && $settings['alt_field'],
);
$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.'),
'#maxlength' => variable_get('image_title_length', 500),
'#weight' => -1,
'#access' => (bool) $item['fid'] && $settings['title_field'],
);
Comments
Comment #1
joelsteidl commentedIt actually throws an error if you try to add more than 128 characters.
PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'field_image_title' at row 1: INSERT INTO {field_data_field_image} (entity_type, entity_id, revision_id, bundle, delta, language, field_image_fid, field_image_alt, field_image_title) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8); Array ( [:db_insert_placeholder_0] => node [:db_insert_placeholder_1] => 59 [:db_insert_placeholder_2] => 59 [:db_insert_placeholder_3] => country_profile [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => 83 [:db_insert_placeholder_7] => [:db_insert_placeholder_8] => Accused perpetrators, Pademba Central Prison Accused perpetrators, Pademba Central Prison Accused perpetrators, Pademba Central Prison Accused perpetrators, Pademba Central Prison Accused perpetrators, Pademba Central Prison Accused perpetrators, Pademba Central Prison Accused perpetrators, Pademba Central Prison Accused perpetrators, Pademba Central Prison Accused perpetrators, Pademba Central Prison ) in field_sql_storage_field_storage_write() (line 425 of /var/www/vhosts/ictj.atendesigngroup.com/httpdocs/modules/field/modules/field_sql_storage/field_sql_storage.module).
I am happy to patch if someone can confirm this is a bug.
Comment #2
off commentedThe same issue!
How can I use a big title for images? Or how can I use a description for the image field like cck and drupal 6 imagefield?
Comment #3
Anonymous (not verified) commented@joelsteidl definitely a bug, I also got that PDOException. Makes sense to me to sync the textfield lengths with their db column lengths.
Comment #4
matrobin commentedsubscribe
Comment #5
btmash commentedThis is actually a duplicate of #1015916: Image field "title" allows more data than database column size.: let's focus our issues on that one which would take care of this.