diff --git a/plup.js b/plup.js
index 66ee691..1e89fd8 100644
--- a/plup.js
+++ b/plup.js
@@ -145,7 +145,7 @@
                     // Add image thumbnail into list of uploaded items
                     $(id +' .plup-list').append(
                       '<li class="ui-state-default">' +
-                      '<div class="plup-thumb-wrapper"><img src="'+ plupInstance.image_style_path + file.target_name + '" title="'+ Drupal.checkPlain(file.target_name) +'" /></div>' +
+                      '<div class="plup-thumb-wrapper"><img src="'+ fileSaved.secure_uri + '" title="'+ Drupal.checkPlain(file.target_name) +'" /></div>' +
                       '<a class="plup-remove-item"></a>' +
                       title_field +
                       alt_field +
diff --git a/plup.module b/plup.module
index 4a38d73..875a519 100644
--- a/plup.module
+++ b/plup.module
@@ -352,7 +352,7 @@ function plup_upload_page() {
   }
 
   // Handle non multipart uploads older WebKit versions didn't support multipart in HTML5
-  if (strpos($contentType, 'multipart') !== false) {
+  if (strpos($contentType, 'multipart') !== FALSE) {
     if (isset($_FILES['file']['tmp_name']) && is_uploaded_file($_FILES['file']['tmp_name'])) {
       // Open temp file
       $out = fopen($targetDir . DIRECTORY_SEPARATOR . $filename, $chunk == 0 ? 'wb' : 'ab');
@@ -416,7 +416,18 @@ function plup_upload_page() {
 
     if ($e === FALSE) {
       $return = file_save($file);
-    } else {
+      // Generate a secure version of file uri for temporary delivery.
+      $instance = plup_get_field_config_by_instance_id($file->arg);
+      if (isset($instance['widget']['settings']['preview_image_style']) && !empty($instance['widget']['settings']['preview_image_style'])) {
+        $file->secure_uri = image_style_url($instance['widget']['settings']['preview_image_style'], $file->uri);
+      }
+      elseif (isset($instance['widget']['settings']['image_style']) && !empty($instance['widget']['settings']['image_style'])) {
+        $file->secure_uri = image_style_url($instance['widget']['settings']['image_style'], $file->uri);
+      }
+      // We build it as a temp but will deliver it as a public.
+      $file->secure_uri = str_replace('system/temporary', variable_get('file_public_path', 'sites/default/files'), $file->secure_uri);
+    }
+    else {
       file_unmanaged_delete($file->uri);
       $return = (object) array('error_message' => $e);
     }
@@ -433,8 +444,7 @@ function plup_upload_page() {
  */
 function plup_plup_file_validation_alter(&$file, &$e) {
   if (!isset($file->arg) || (isset($file->arg) && is_numeric($file->arg))) {
-    $instance = db_select('field_config_instance','i')->fields('i', array('data'))->condition('id', $file->arg)->execute()->fetchField();
-    $instance = unserialize($instance);
+    $instance = plup_get_field_config_by_instance_id($file->arg);
     $settings = $instance['settings'];
 
     // Check if file is image
@@ -474,6 +484,24 @@ function plup_plup_file_validation_alter(&$file, &$e) {
   }
 }
 
+/**
+ * Gets the configuration of the field instance by instance id.
+ *
+ * @param int $instance_id
+ *   Field instance id.
+ *
+ * @return array Field instance configuration.
+ */
+function plup_get_field_config_by_instance_id($instance_id) {
+  $config = &drupal_static(__FUNCTION__);
+
+  if (!isset($config[$instance_id])) {
+    $result = db_query('SELECT data from {field_config_instance} WHERE id = :id', array(':id' => $instance_id));
+    $config[$instance_id] = unserialize($result->fetchField());
+  }
+
+  return $config[$instance_id];
+}
 
 /*********************************************
  *            FIELD WIDGET
@@ -631,4 +659,4 @@ function plup_field_attach_presave($entity_type, $entity) {
       }
     }
   }
-}
\ No newline at end of file
+}
