? imagecache-js.patch
Index: imagecache.js
===================================================================
RCS file: imagecache.js
diff -N imagecache.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ imagecache.js	27 Sep 2010 05:39:57 -0000
@@ -0,0 +1,50 @@
+/*global Drupal,jQuery */
+
+(function($) {
+  "use strict";
+
+  Drupal.imagecache = {
+    /**
+     * Remove the files directory prefix from a path.
+     */
+    stripFileDirectory: function(path) {
+      var filePath = Drupal.settings.imagecache.filesDirectory;
+      if (path.substr(0, filePath.length + 1) === filePath + '/') {
+        path = path.substr(filePath.length + 1);
+      }
+      return path;
+    },
+
+    createUrl: function(preset, path) {
+      var stripped = this.stripFileDirectory(path);
+      // If the preset is invalid, return the path to the original image.
+      if ($.inArray(preset, Drupal.settings.imagecache.presets) !== -1) {
+        return Drupal.settings.imagecache.filesUrl + '/imagecache/' + preset + '/' + stripped;
+      }
+      return Drupal.settings.imagecache.filesUrl + '/' + stripped;
+    }
+  };
+
+  Drupal.theme.prototype.imagecache = function(preset, path, alt, title, attributes) {
+    var image;
+    image = new Image();
+
+    image.onload = function() {
+      $(this).attr({
+        width: $(image).width(),
+        height: $(image).height()
+      });
+    };
+
+    image.src = Drupal.imagecache.createUrl(preset, path);
+    image = $.extend(image, {
+      title: title,
+      alt: alt
+    }, attributes);
+
+    return image;
+  };
+})(jQuery);
+
+/*jslint browser: true, onevar: true, undef: true */
+
Index: imagecache.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imagecache/imagecache.module,v
retrieving revision 1.112.2.9
diff -u -p -r1.112.2.9 imagecache.module
--- imagecache.module	26 May 2010 21:08:58 -0000	1.112.2.9
+++ imagecache.module	27 Sep 2010 05:39:59 -0000
@@ -879,6 +879,28 @@ function theme_imagecache_imagelink($pre
 }
 
 /**
+ * Imagecache JS settings and theme function.
+ */
+function imagecache_add_js() {
+  static $added;
+  if (!$added) {
+    $added = TRUE;
+    drupal_add_js(drupal_get_path('module', 'imagecache') .'/imagecache.js');
+
+    $mode = variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC);
+    if ($mode == FILE_DOWNLOADS_PUBLIC) {
+      $settings['filesUrl'] = $GLOBALS['base_path'] . file_directory_path();
+    }
+    elseif ($mode == FILE_DOWNLOADS_PRIVATE) {
+      $settings['filesUrl'] = 'system/files';
+    }
+    $settings['filesDirectory'] = file_directory_path();
+    $settings['presets'] = array_keys(imagecache_presets());
+    drupal_add_js(array('imagecache' => $settings), 'setting');
+  }
+}
+
+/**
  *  ImageCache 2.x API
  *
  *  The API for imagecache has changed.  The 2.x API returns more structured
