diff --git a/media_feeds.module b/media_feeds.module
index c034a75..63c8162 100644
--- a/media_feeds.module
+++ b/media_feeds.module
@@ -76,113 +76,115 @@ function media_feeds_set_target($source, $entity, $target, $values, $config = ar
   list($target, $provider) = explode(':', $target, 2) + array(1 => 'MediaFeedsInternetProvider');
 
   foreach ($values as $value) {
-    try {
-      // Find a provider to create a file object.
-      $provider = new $provider($value, $config);
-
-      // Validate and get a file object.
-      $provider->validate();
-      $file = $provider->getFileObject();
-      if (!$file) {
-        drupal_set_message(t('Failed to get the file object for %value.', array('%value' => (string) $value)));
-        continue;
-      }
-
-      // Look for the field instance settings.
-      $instance = field_info_instance($entity->feeds_item->entity_type, $target, $entity->type);
-
-      // Validate the type.
-      if ($field_info['type'] == 'media') {
-        $allowed_types = $instance['widget']['settings']['allowed_types'];
-      }
-      elseif ($field_info['type'] == 'image') {
-        $allowed_types = array('image');
-      }
-      if (!empty($allowed_types)) {
-        $errors = media_file_validate_types($file, $allowed_types);
-        if (count($errors)) {
-          foreach ($errors as $error) {
-            drupal_set_message(filter_xss($error), 'error');
-          }
+    if (!empty($value)) {
+      try {
+        // Find a provider to create a file object.
+        $provider = new $provider($value, $config);
+
+        // Validate and get a file object.
+        $provider->validate();
+        $file = $provider->getFileObject();
+        if (!$file) {
+          drupal_set_message(t('Failed to get the file object for %value.', array('%value' => (string) $value)));
           continue;
         }
-      }
 
-      if (file_uri_scheme($file->uri) == 'temporary') {
-        // Select the URI scheme that should be used to store a permanent copy
-        // of a temporary file.
-        if (in_array('public', $allowed_schemes)) {
-          $destination = 'public';
-        }
-        elseif (in_array('private', $allowed_schemes)) {
-          $destination = 'private';
+        // Look for the field instance settings.
+        $instance = field_info_instance($entity->feeds_item->entity_type, $target, $entity->type);
+
+        // Validate the type.
+        if ($field_info['type'] == 'media') {
+          $allowed_types = $instance['widget']['settings']['allowed_types'];
         }
-        else {
-          $destination = reset($allowed_schemes);
+        elseif ($field_info['type'] == 'image') {
+          $allowed_types = array('image');
         }
-        if (!$destination) {
-          drupal_set_message(t('Could not handle file with scheme <em>temporary://</em> because there is no scheme available for storing a permanent copy.'), 'error');
-          continue;
+        if (!empty($allowed_types)) {
+          $errors = media_file_validate_types($file, $allowed_types);
+          if (count($errors)) {
+            foreach ($errors as $error) {
+              drupal_set_message(filter_xss($error), 'error');
+            }
+            continue;
+          }
         }
 
-        // Copy file to a permanent location.
-        $file->status = FILE_STATUS_PERMANENT;
-        $file = file_copy($file, $destination . '://' . $file->basename);
-        if (!$file) {
-          drupal_set_message(t('Failed to copy file to a permanent location.'));
-          continue;
-        }
-      }
-      else {
-        // Validate the URI scheme.
-        // If public is allowed, also allow schemes supported by
-        // MediaInternetFileHandler (http, ...).
-        if ($field_info['type'] == 'media') {
-          $allowed_schemes = $instance['widget']['settings']['allowed_schemes'];
+        if (file_uri_scheme($file->uri) == 'temporary') {
+          // Select the URI scheme that should be used to store a permanent copy
+          // of a temporary file.
           if (in_array('public', $allowed_schemes)) {
-            $fromurlschemes = media_variable_get('fromurl_supported_schemes');
-            foreach ($fromurlschemes as $fromurlscheme) {
-              $allowed_schemes[$fromurlscheme] = $fromurlscheme;
-            }
+            $destination = 'public';
+          }
+          elseif (in_array('private', $allowed_schemes)) {
+            $destination = 'private';
+          }
+          else {
+            $destination = reset($allowed_schemes);
+          }
+          if (!$destination) {
+            drupal_set_message(t('Could not handle file with scheme <em>temporary://</em> because there is no scheme available for storing a permanent copy.'), 'error');
+            continue;
           }
-          $scheme = file_uri_scheme($file->uri);
-          if (!in_array($scheme, $allowed_schemes)) {
-            drupal_set_message(t('Scheme %scheme not allowed for %target.', array('%scheme' => $scheme . '://', '%target' => $target)), 'error');
+
+          // Copy file to a permanent location.
+          $file->status = FILE_STATUS_PERMANENT;
+          $file = file_copy($file, $destination . '://' . $file->basename);
+          if (!$file) {
+            drupal_set_message(t('Failed to copy file to a permanent location.'));
             continue;
           }
         }
+        else {
+          // Validate the URI scheme.
+          // If public is allowed, also allow schemes supported by
+          // MediaInternetFileHandler (http, ...).
+          if ($field_info['type'] == 'media') {
+            $allowed_schemes = $instance['widget']['settings']['allowed_schemes'];
+            if (in_array('public', $allowed_schemes)) {
+              $fromurlschemes = media_variable_get('fromurl_supported_schemes');
+              foreach ($fromurlschemes as $fromurlscheme) {
+                $allowed_schemes[$fromurlscheme] = $fromurlscheme;
+              }
+            }
+            $scheme = file_uri_scheme($file->uri);
+            if (!in_array($scheme, $allowed_schemes)) {
+              drupal_set_message(t('Scheme %scheme not allowed for %target.', array('%scheme' => $scheme . '://', '%target' => $target)), 'error');
+              continue;
+            }
+          }
 
-        // Save file.
-        $file = $provider->save();
-        if (!$file) {
-          drupal_set_message(t('Failed to save the file.'), 'error');
-          continue;
+          // Save file.
+          $file = $provider->save();
+          if (!$file) {
+            drupal_set_message(t('Failed to save the file.'), 'error');
+            continue;
+          }
         }
-      }
 
-      // Apply author settings to the file.
-      if ((empty($file->uid) && !empty($entity->uid)) || $file->uid != $entity->uid) {
-        $file->uid = $entity->uid;
-        if (!file_save($file)) {
-          drupal_set_message(t('Failed to apply the author settings to the file.'), 'warning');
+        // Apply author settings to the file.
+        if ((empty($file->uid) && !empty($entity->uid)) || $file->uid != $entity->uid) {
+          $file->uid = $entity->uid;
+          if (!file_save($file)) {
+            drupal_set_message(t('Failed to apply the author settings to the file.'), 'warning');
+          }
         }
-      }
 
-      // Attach the file to the field.
-      $result = array(
-        'fid' => $file->fid,
-      );
-      if ($field_info['type'] == 'file') {
-        $result += array(
-          'display' => 1,
-          'description' => '',
+        // Attach the file to the field.
+        $result = array(
+          'fid' => $file->fid,
         );
+        if ($field_info['type'] == 'file') {
+          $result += array(
+            'display' => 1,
+            'description' => '',
+          );
+        }
+        $field[LANGUAGE_NONE][] = $result;
+      } catch (MediaInternetNoHandlerException $e) {
+        drupal_set_message($e->getMessage(), 'error');
+      } catch (MediaInternetValidationException $e) {
+        drupal_set_message($e->getMessage(), 'error');
       }
-      $field[LANGUAGE_NONE][] = $result;
-    } catch (MediaInternetNoHandlerException $e) {
-      drupal_set_message($e->getMessage(), 'error');
-    } catch (MediaInternetValidationException $e) {
-      drupal_set_message($e->getMessage(), 'error');
     }
   }
 
