You are here

function image_update_7005 in Drupal 7

Add a column to the 'image_style' table to store administrative labels.

Related topics

File

modules/image/image.install, line 461
Install, update and uninstall functions for the image module.

Code

function image_update_7005() {
  $field = array(
    'type' => 'varchar',
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
    'description' => 'The style administrative name.',
  );
  db_add_field('image_styles', 'label', $field);

  // Do a direct query here, rather than calling image_styles(),
  // in case Image module is disabled.
  $styles = db_query('SELECT name FROM {image_styles}')
    ->fetchCol();
  foreach ($styles as $style) {
    db_update('image_styles')
      ->fields(array(
      'label' => $style,
    ))
      ->condition('name', $style)
      ->execute();
  }
}