--- adaptive_image.module.orig	2011-11-29 15:51:31.000000000 +1100
+++ adaptive_image.module	2011-11-29 15:50:56.000000000 +1100
@@ -15,7 +15,7 @@
 function adaptive_image_init() {
   // No need for drupal behaviours, jquery compatibility wrapper nor ready event
   // This is inline to prevent wait time while loading the script
-  $js = "document.cookie = 'adaptive_image=' + Math.max(screen.width, screen.height) + '; path=/';";
+  $js = "document.cookie = 'adaptive_image=' + window.innerWidth + '; path=/';";
   drupal_add_js($js,
     // First-come, first-served
     array(
@@ -154,14 +154,8 @@ function adaptive_image_preprocess_image
       $resolution = adaptive_image_resolution($resolutions);
 
       // Only construct direct path if not private
-      if (!strpos($variables['path'], '/system/') && is_numeric($resolution)) {
-        $path_parts = pathinfo($variables['path']);
-        $derivative_uri = $path_parts['dirname'] . '/' . $resolution . '/' . $path_parts['basename'];
-      }
-
-      if (isset($derivative_uri) && file_exists(str_replace($base_url, '.', $derivative_uri))) {
-        // Deliver existing path to bypass menu callback
-        $variables['path'] = $derivative_uri;
+      if (!strpos($variables['path'], '/system/') && is_numeric($resolution) && array_key_exists($variables['style_name'] . '_' . $resolution, image_styles(TRUE))) {
+         $variables['path'] = str_replace('styles/' . $variables['style_name'], 'styles/' . $variables['style_name'] . '_' . $resolution, $variables['path']);
       }
       else {
         // Reconstruct the image path to %/%style_name/adaptive-image/% to
