diff --git a/customactions/imagecache_customactions.module b/customactions/imagecache_customactions.module
index 23c6d93..250136b 100644
--- a/customactions/imagecache_customactions.module
+++ b/customactions/imagecache_customactions.module
@@ -98,7 +98,7 @@ function imagecache_customactions_form($action) {
       For convenience, the images current <code>$image->info</code> variables
       - <code>$width</code>, <code>$height</code> are available in the current scope.
       <br/>Do not use %php tags. </p>
-      <p>If possible, the owning $node object may also be available.</p>
+      <p>If possible, an array of owning $fields may also be available.</p>
       <p>Note that executing incorrect PHP-code can break your Drupal site.</p>
       <p>If you are using a WYSIWYG, you must disable it for this edit area.</p>
 <h3>example:</h3>
@@ -138,13 +138,13 @@ function imagecache_customactions_image($image, $action) {
   // Pull the images $width and $height out to play
   @extract($image->info);
   // And maybe the owner node data could be useful
-  if (function_exists('imagecache_actions_node_from_filepath')) {
-    $node = imagecache_actions_node_from_filepath($image->source);
+  if (function_exists('imagecache_actions_fields_from_filepath')) {
+    $fields = imagecache_actions_fields_from_filepath($image->source);
   }
   // To get clever and do things post-process, let the process know what the final filename will be.
-  // It seems we cannot see what $dst or even our onwing presetname is.
+  // It seems we cannot see what $dst or even our owning presetname is.
   // But we do know what the URL was the invoked this action! that's out filename-to-be!
-  $dst = $_REQUEST['q'];
+  $dst = isset($_REQUEST['q']) ? $_REQUEST['q'] : NULL;
 
   $result = eval($action['text']);
   return $result;
diff --git a/utility.inc b/utility.inc
index 4be8e3e..153667f 100755
--- a/utility.inc
+++ b/utility.inc
@@ -236,131 +236,28 @@ function imagecache_include_standard_actions() {
   //include_once DRUPAL_ROOT . '/' . $cropaction['file'];
 }
 
-
-
 /**
- * Given only a file filename, track back to see if we can detect the parent
- * node and provide some context info.
- *
- * This will be different in different cases.
- * Supported :
- * image.module image nodes
- * imagefield cck fields (may be multiple)
- * upload.module attachments
- *
- * TODO: image_attach attachments
+ * Given a file path relative the default file scheme, tries to locate it and,
+ * is successful, finds all fields that use it.
  *
  * @param $filepath
- * @param $file_data MAY get some details filled in on it by reference if data
- * was found.
  *
- * @return a loaded $node object
+ * @return
+ *   A nested array of basic entity data, grouped by entity type and field name.
  */
-function imagecache_actions_node_from_filepath($filepath, &$file_data = NULL) {
-
-  // lookup upload.module attachments
-  if (module_exists('upload')) {
-    $sql = "SELECT nid, f.fid FROM {upload} AS u INNER JOIN {files} AS f ON u.fid = f.fid WHERE f.filepath = '%s'";
-    $results = db_query_range("SELECT nid, f.fid FROM {upload} AS u INNER JOIN {files} AS f ON u.fid = f.fid WHERE f.filepath = :f.filepath", array(':f.filepath' => $filepath), 0, 1);
-    if ( $row = db_fetch_array($results)) {
-      // Return immediately
-      $node = node_load($row['nid']);
-      // also include the file description
-      $file_data = $node->files[$row['fid']];
-      return $node;
-    }
-  }
-
-  // Lookup image.module nodes
-  if (module_exists('image')) {
-    $sql = "SELECT nid FROM {image} AS i INNER JOIN {files} AS f ON i.fid = f.fid WHERE f.filepath = '%s'";
-    if ( $nid = db_query_range("SELECT nid FROM {image} AS i INNER JOIN {files} AS f ON i.fid = f.fid WHERE f.filepath = :f.filepath", array(':f.filepath' => $filepath), 0, 1)->fetchField()) {
-      // Return immediately
-      return node_load($nid);
-    }
-  }
-
-
-  // Lookup filefield imagefield CCK attachments.
-  //
-  // Drupal 6 version here based largely on work done by mikeytown2
-  // http://drupal.org/node/363434
-
-  // This is a terrible way to retrieve information, but CCK doesn't provide a way to reverse-lookup like this
-  // BAD CODE follows
-  // If someone could roll these DBlookups into a smaller ball, that would be fun.
-  // Due to CCKs use of dynamically created table names .. I don't know how.
-
-  // Multiple file ID's might have the same name, get all
-  // (but return just the first successful match)
-  $result = db_query("SELECT fid FROM {files} WHERE filepath = :filepath", array(':filepath' => $filepath));
-  $fids = array();
-  while ($row = db_fetch_array($result)) {
-    $fids[] = $row['fid'];
+function imagecache_actions_fields_from_filepath($filepath) {
+  if (!module_exists('file')) {
+    return;
   }
 
-  if (! empty($fids)) {
-    // Find out if any filefield contains this file, and if so, which field
-    // and node it belongs to. Required for later access checking.
-    // CCK field analysis is in the outer loop,
-    // fids are scanned in the inner loop for a little speed.
-
-    // Get A List Of ALL CCK Fields and look for them individually,
-    // it's the only way we can reverse the lookups
-    foreach (content_fields() as $field) {
-      // If Field is an Image (imagefield.module) or filefield then
-      if ($field['type'] == 'image' || $field['type'] == 'filefield') {
-        // Need to do lots of lookups to find out what the storage tables look like.
-        // Grab All DB Column Names for that CCK Field
-        $db_info = content_database_info($field);
-        // Get Content Type DB name - FROM statement
-        $tablename = $db_info['table'];
-        //Get File ID DB Column Name - WHERE statement
-        $fid_column = $db_info['columns']['fid']['column'];
-
-        // Construct a Query that looks for all known fids in one go.
-        // eg:
-        // SELECT nid FROM content_type_story
-        //   WHERE field_illustration_fid = 77
-        //   OR field_illustration_fid = 99;
-
-        $wheres = array();
-        $query_args = array();
-        foreach ($fids as $fid) {
-          $wheres[] = " %s = %d ";
-          $query_args[] = $fid_column;
-          $query_args[] = $fid;
-        }
-
-        // TODO Please convert this statement to the D7 database API syntax.
-        $result = db_query('SELECT nid FROM {' . $tablename . '} WHERE ' . join(' OR ', $wheres), $query_args);
-
-        while ($row = db_fetch_array($result)) {
-          // This while is a dummy loop - Just break out and return the first matching node.
-          // If more than one node owns this image then ???
-          $node = node_load($row['nid']);
-
-          // Add even more info - the description "data" that MAY have been added
-          // to this file on this node using filefield_meta and stuff.
-          // Return the data associated specifically with this file also;
-          // Do this via the handle on the file_data object we were passed in.
-          // Slightly mushed together - I want it to mostly resemble the traditional file attachment object.
-
-          // We have the node but lost track of the file in the process.
-          // Need to scan again to make sure we got the right one :-{
-          if ( $file_fields = $node->{$field['field_name']} ) {
-            foreach ($file_fields as $file_field) {
-              if ($file_field['fid'] == $fid) {
-                $actual_file = $file_field;
-              }
-            }
-            $file_data = (object) array_merge((array) $file_data, $actual_file['data'], $actual_file);
+  $files = file_load_multiple(array(), array('uri' => file_build_uri($filepath)));
 
-          }
-          return $node;
-        }
-      }
+  if ($files) {
+    $fields = array();
+    foreach ($files as $fid => $file) {
+      $fields[$fid] = file_get_file_references($file, NULL, FIELD_LOAD_CURRENT, 'image');
     }
+    return $fields;
   }
 }
 
