diff --git a/imagecache_token.module b/imagecache_token.module
index c083ec8..06537c4 100644
--- a/imagecache_token.module
+++ b/imagecache_token.module
@@ -180,54 +180,78 @@ function imagecache_token_tokens($type, $tokens, array $data = array(), array $o
       // Other tokens.
       else {
         foreach ($data['image-field'] as $field) {
-          if ($attribute == 'render') {
-            $output[] = theme('image_formatter', array('item' => $field, 'image_style' => $type));
-          }
-          elseif (isset($attribute) && !empty($attribute) && isset($field[$attribute])) {
-            // These attributes are for the resized image, rather than the
-            // original, so load the resized image and obtain its meta data.
-            if (in_array($attribute, array('width', 'height', 'mimetype', 'extension', 'filesize'))) {
-              $styled_uri = image_style_path($type, $field['uri']);
-              $style = image_style_load($type);
-
-              // Imagecrop module support.
-              global $imagecrop_style;
-              $imagecrop_style = $type;
-
-              // Create a derivative of the image for this style.
-              image_style_create_derivative($style, $field['uri'], $styled_uri);
-
-              // If the styled image's information wasn't loaded before then
-              // load it now; as this process is a little heavy, the
-              // information will be statically cached to avoid needing to
-              // reload the details for another token.
-              if (empty($images_style_data[$styled_uri])) {
-                $images_style_data[$styled_uri] = image_get_info($styled_uri);
-              }
+          if (isset($attribute) && !empty($attribute)) {
+            switch ($attribute) {
+              case 'render':
+                $output[] = theme('image_formatter', array('item' => $field, 'image_style' => $type));
+                break;
 
-              // Check for each supported attribute.
-              if ($attribute == 'width') {
-                $output[] = $images_style_data[$styled_uri]['width'];
-              }
-              if ($attribute == 'height') {
-                $output[] = $images_style_data[$styled_uri]['height'];
-              }
-              if ($attribute == 'mimetype') {
-                $output[] = $images_style_data[$styled_uri]['mime_type'];
-              }
-              if ($attribute == 'extension') {
-                $output[] = $images_style_data[$styled_uri]['extension'];
-              }
-              if ($attribute == 'filesize') {
-                $output[] = $images_style_data[$styled_uri]['file_size'];
-              }
-            }
-            else {
-              $output[] = $field[$attribute];
+              case 'mimetype':
+              case 'width':
+              case 'height':
+              case 'extension':
+              case 'filesize':
+                $styled_uri = image_style_path($type, $field['uri']);
+
+                // Only generate the image if it doesn't already exist.
+                if (!file_exists($styled_uri)) {
+                  $style = image_style_load($type);
+                  // Imagecrop module support.
+                  global $imagecrop_style;
+                  $imagecrop_style = $type;
+                  // Create a derivative of the image for this style.
+                  image_style_create_derivative($style, $field['uri'], $styled_uri);
+                }
+
+                // If the styled image's information wasn't loaded before then
+                // load it now; as this process is a little heavy, the
+                // information will be statically cached to avoid needing to
+                // reload the details for another token.
+                if (empty($images_style_data[$styled_uri])) {
+                  $images_style_data[$styled_uri] = image_get_info($styled_uri);
+                }
+
+                switch ($attribute) {
+                  case 'width':
+                    $output[] = $images_style_data[$styled_uri]['width'];
+                    break;
+
+                  case 'height':
+                    $output[] = $images_style_data[$styled_uri]['height'];
+                    break;
+
+                  case 'mimetype':
+                    $output[] = $images_style_data[$styled_uri]['mime_type'];
+                    break;
+
+                  case 'extension':
+                    $output[] = $images_style_data[$styled_uri]['extension'];
+                    break;
+
+                  case 'filesize':
+                    $output[] = $images_style_data[$styled_uri]['file_size'];
+                    break;
+                }
+                break;
+
+              case 'path':
+                if (isset($explode[2]) && $explode[2] === 'relative') {
+                  $url  = parse_url(image_style_url($type, $field['uri']));
+                  $output[] = $url['path'];
+                }
+                else {
+                  $output[] = image_style_url($type, $field['uri']);
+                }
+                break;
+
+              default:
+                if (isset($field[$attribute])) {
+                  $output[] = $field[$attribute];
+                }
             }
           }
           else {
-            $output[] = image_style_url($token, $field['uri']);
+            $output[] = image_style_url($type, $field['uri']);
           }
         }
 
@@ -250,6 +274,7 @@ function _imagegecache_token_image_attributes() {
   return array(
     'style_name' => NULL,
     'path' => NULL,
+    'path:relative' => NULL,
     'width' => NULL,
     'height' => NULL,
     'extension' => NULL,
