diff --git a/dummyimage.module b/dummyimage.module
index 6b52b90..ff34ff1 100644
--- a/dummyimage.module
+++ b/dummyimage.module
@@ -106,7 +106,9 @@ function dummyimage_preprocess_image(&$variables) {
   }
   switch (variable_get('dummyimages_generate', DUMMYIMAGE_GENERATE_NONE)) {
     case DUMMYIMAGE_GENERATE_MISSING:
-      if (is_file($variables['path'])) {
+      global $base_url;
+      preg_match('@' . preg_quote($base_url) . '/(.*)(styles/' . $variables['style_name'] . '/' . file_default_scheme() . '/)(.*)@', $variables['path'], $matches);
+      if (file_exists($matches[1] . $matches[3])) {
         break;
       }
     case DUMMYIMAGE_GENERATE_ALL:
