Description of the need
Add hook_field_schema_alter(), as described in https://www.drupal.org/node/691932, which has been merged into Drupal 7 core as of 7.99. See https://www.drupal.org/node/3406312
For the reasons we have hook_schema_alter() - mainly site-specific tweaks, we should allow the same for field storage.
It would make it easier to implement a contrib module (like date_repeat) that would alter core fields (like core date fields).
Proposed solution
Apply this patch: https://www.drupal.org/files/issues/2023-03-16/drupal-field_schema_alter... or similar.
Alternatives that have been considered
hook_schema_alter() can be used too but it requires checking for each table to see if it's of the right field type and also requires also handling field creation and deletion so it's more work than the proposed new hook.
Example implementation
``` /** * Allow modules to alter the schema for a field. * * @param array $schema * The schema definition as returned by hook_field_schema(). * @param array $field * The field definition. * * @see field_retrieve_schema() */ function hook_field_schema_alter(&$schema, $field) { if ($field['type'] == 'image') { // Alter the length of a field. $schema['columns']['alt']['length'] = 2048; // Add an additional column of data. $schema['columns']['additional_column'] = array( 'description' => "Additional column added to image field table.", 'type' => 'varchar', 'length' => 128, 'not null' => FALSE, ); // Add an additional index. $schema['indexes']['fid_additional_column'] = array('fid', 'additional_column'); } } ````
Recent comments
Hi. I use the "[node:title] | [site:name]" tokens for the main image of news articles, blog posts, and similar publications. It's a quick and practical automatic ALT.
How to Improve SEO Performance in Backdrop CMS
I understand how tokens work, but not so much their practical use in image alt/text (maybe caption?) text. Could you give an example or two?
How to Improve SEO Performance in Backdrop CMS
https://backdropcms.org/project/metatag https://backdropcms.org/project/xmlsitemap https://backdropcms.org/project/imagefield_tokens These are more powerful modules, in my opinion...
How to Improve SEO Performance in Backdrop CMS