From 4725a3e75150d7f19a00de4aabdd11f2a0c5b0a7 Mon Sep 17 00:00:00 2001 From: Ashok Modi Date: Tue, 1 Mar 2011 16:04:20 -0800 Subject: [PATCH] Issue #1015916 by Kevin Hankens, BTMash: Update the image alt and title fields to be same length as in variable_get() --- modules/image/image.install | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 40 insertions(+), 2 deletions(-) diff --git a/modules/image/image.install b/modules/image/image.install index fbd20de..d612ff0 100644 --- a/modules/image/image.install +++ b/modules/image/image.install @@ -121,13 +121,13 @@ function image_field_schema($field) { 'alt' => array( 'description' => "Alternative image text, for the image's 'alt' attribute.", 'type' => 'varchar', - 'length' => 128, + 'length' => variable_get('image_alt_length', 80), 'not null' => FALSE, ), 'title' => array( 'description' => "Image title text, for the image's 'title' attribute.", 'type' => 'varchar', - 'length' => 128, + 'length' => variable_get('image_title_length', 500), 'not null' => FALSE, ), ), @@ -244,6 +244,44 @@ function image_update_7001() { } /** + * Update the image alt and title fields to be the same length as their + * variable_get() counterparts which are referenced through the module. + */ +function image_update_7002() { + $alt_spec = array( + 'type' => 'varchar', + 'length' => variable_get('image_alt_length', 80), + 'not null' => FALSE, + ); + $title_spec = array( + 'type' => 'varchar', + 'length' => variable_get('image_title_length', 500), + 'not null' => FALSE, + ); + $fields = _update_7000_field_read_fields(array( + 'module' => 'image', + 'storage_type' => 'field_sql_storage', + )); + foreach ($fields as $field_name => $field) { + if ($field['deleted']) { + $table = "field_deleted_data_{$field['id']}"; + $revision_table = "field_deleted_revision_{$field['id']}"; + } + else { + $table = "field_data_{$field['field_name']}"; + $revision_table = "field_revision_{$field['field_name']}"; + } + $alt_column = $field['field_name'] . '_' . 'alt'; + db_change_field($table, $alt_column, $alt_column, $alt_spec); + db_change_field($revision_table, $alt_column, $alt_column, $alt_spec); + + $title_column = $field['field_name'] . '_' . 'title'; + db_change_field($table, $title_column, $title_column, $title_spec); + db_change_field($revision_table, $title_column, $title_column, $title_spec); + } +} + +/** * Implements hook_requirements() to check the PHP GD Library. * * @param $phase -- 1.7.4.1