--- image_exact.module.original	2007-07-11 19:13:25.000000000 +0200
+++ image_exact.module	2007-07-11 20:43:48.000000000 +0200
@@ -77,29 +77,35 @@ function image_exact_admin_settings() {
   return system_settings_form($form);
 }
 
+
 /*
-* Implementation of hook_nodeapi
+* Implementation of hook_image_alter
 *
-* Looks for images and if the setting is set will resize thumbs
+* Alters image derivatives build by image module
 */
 
-function image_exact_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
-  //Set thumbnail final dimensions here - use settings from image content type.
-  if ($node->type == 'image' && $op == 'validate' && variable_get('image_exact_thumbs', 1)) {
+function image_exact_image_alter($node, $destination, $sizelabel) {
+
+  if (variable_get('image_exact_thumbs', 1)) {
+
+    // Find parameters and decide if resize or not
     $sizes = _image_get_sizes();
+    unset ($final_w);
     foreach(variable_get('image_exact_size', array(0)) as $i) {
-//     for ($i = 0; $i < 5; $i++) {
-      $source = file_create_path($node->images['_original']);
-      $destination = file_create_path($node->images[$sizes[$i]['label']]);
-      $final_w = $sizes[$i]['width'];
-      $final_h = $sizes[$i]['height'];
-      if ($final_w && $final_h) {
-        image_exact_resize($source, $destination, $final_w, $final_h);
+      if ($sizelabel == $sizes[$i]['label']) {
+        $final_w = $sizes[$i]['width'];
+        $final_h = $sizes[$i]['height'];
+        $source = file_create_path($node->images[IMAGE_ORIGINAL]);
       }
     }
+
+    if ($final_w && $final_h) {
+      image_exact_resize($source, $destination, $final_w, $final_h);
+    }
   }
 }
 
+
 /*
 * Implementation of hook_user
 * Handles exact-sizes for avatars
