--- ./modules/imagefield/imagefield.install	Tue Nov 11 17:53:22 2008
+++ ./modules/imagefield/imagefield.install	Tue Nov 11 17:58:25 2008
@@ -282,3 +282,22 @@
   return array();
 }
  
+/**
+ * Create missing admin thumbnails.
+ * @todo: batch process it. Here we will rapidly enter a PHP timeout.
+ */
+function imagefield_update_6003() {
+  module_load_include('inc', 'content', 'includes/content.crud');
+  module_load_include('inc', 'imagefield', 'imagefield_file');
+  foreach (content_fields() as $field) {
+    if ($field['type'] != 'image') continue;
+    $db_info = content_database_info($field);
+    $result = db_query("SELECT f.* FROM {{$db_info['table']}} ctf JOIN {files} f ON ctf.{$db_info['columns']['fid']['column']} = f.fid");
+    while ($row = db_fetch_array($result)) {
+      if (!file_exists(imagefield_file_admin_thumb_path($row))) {
+        imagefield_file_insert((object)$row);
+      }
+    }
+  }
+  return array();
+}
