Index: imagecache.js
===================================================================
RCS file: imagecache.js
diff -N imagecache.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ imagecache.js	6 May 2010 02:24:06 -0000
@@ -0,0 +1,47 @@
+/*global Drupal,$ */
+
+"use strict";
+
+Drupal.imagecache = {
+  getPath: function (preset, path) {
+    var stripFileDirectory, imagecachePath;
+
+    stripFileDirectory = function (path) {
+      if (path.substr(0, Drupal.settings.imagecache.filePath.length + 1) === Drupal.settings.imagecache.filePath + '/') {
+        path = path.substr(Drupal.settings.imagecache.filePath.length + 1);
+      }
+      return path;
+    };
+
+    // If the preset is invalid, return the path to the original image.
+    imagecachePath = Drupal.settings.imagecache.filePath;
+    if ($.inArray(preset, Drupal.settings.imagecache.presets)) {
+      imagecachePath += '/imagecache/' + preset;
+    }
+    imagecachePath += '/' + stripFileDirectory(path);
+
+    return imagecachePath;
+  }
+};
+
+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.settings.basePath + Drupal.imagecache.getPath(preset, path);
+  image = $.extend(image, {
+    title: title,
+    alt: alt
+  }, attributes);
+
+  return image;
+};
+
+/*jslint white: true, browser: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true, maxerr: 50, indent: 2 */
Index: imagecache.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/imagecache/imagecache.module,v
retrieving revision 1.112.2.6
diff -u -p -r1.112.2.6 imagecache.module
--- imagecache.module	3 May 2010 16:15:55 -0000	1.112.2.6
+++ imagecache.module	6 May 2010 02:24:06 -0000
@@ -863,6 +863,22 @@ 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');
+    $settings = array(
+      'filePath' => file_directory_path(),
+      '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
