You are here

function video_embed_field_update_7002 in Video Embed Field 7.2

Adds field for storing the path to the video thumbnail.

File

./video_embed_field.install, line 149
Install, update and uninstall functions for the video_embed_field module.

Code

function video_embed_field_update_7002() {

  // Get the list of fields of type 'video_embed_field'.
  $video_embed_fields = array();
  foreach (field_info_fields() as $field_name => $field_info) {
    if ($field_info['type'] == 'video_embed_field') {
      $video_embed_fields[$field_name] = field_read_field($field_name);
    }
  }
  foreach ($video_embed_fields as $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']}";
    }
    $column = $field['field_name'] . '_thumbnail_path';
    db_add_field($table, $column, array(
      'type' => 'varchar',
      'length' => 512,
      'default' => '',
    ));
    db_add_field($revision_table, $column, array(
      'type' => 'varchar',
      'length' => 512,
      'default' => '',
    ));
  }
  return t('Thumbnail column added.');
}