diff --git a/core/modules/image/image.module b/core/modules/image/image.module
index 472cad4..be4bca6 100644
--- a/core/modules/image/image.module
+++ b/core/modules/image/image.module
@@ -403,9 +403,15 @@ function image_entity_presave(EntityInterface $entity) {
   if ($fid) {
     $original_fid = isset($entity->original) ? $entity->original->settings['default_image']['fid'] : NULL;
     if ($fid != $original_fid) {
-      $image = \Drupal::service('image.factory')->get(file_load($fid)->getFileUri());
-      $entity->settings['default_image']['width'] = $image->getWidth();
-      $entity->settings['default_image']['height'] = $image->getHeight();
+      $file = file_load($fid);
+      if ($file) {
+        $image = \Drupal::service('image.factory')->get($file->getFileUri());
+        $entity->settings['default_image']['width'] = $image->getWidth();
+        $entity->settings['default_image']['height'] = $image->getHeight();
+      }
+      else {
+        $entity->settings['default_image']['fid'] = NULL;
+      }
     }
   }
   else {
diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php
index d162cd3..7489011 100644
--- a/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php
+++ b/core/modules/image/lib/Drupal/image/Tests/ImageFieldDefaultImagesTest.php
@@ -289,4 +289,43 @@ public function testDefaultImages() {
     );
   }
 
+  /**
+   * Tests image field and instance having an invalid default image.
+   */
+  public  function testInvalidDefaultImage() {
+    $field = array(
+      'name' => drupal_strtolower($this->randomName()),
+      'entity_type' => 'node',
+      'type' => 'image',
+      'settings' => array(
+        'default_image' => array(
+          'fid' => mt_rand(100, 999999),
+        )
+      ),
+    );
+    $instance = array(
+      'field_name' => $field['name'],
+      'label' => $this->randomName(),
+      'entity_type' => 'node',
+      'bundle' => 'page',
+      'settings' => array(
+        'default_image' => array(
+          'fid' => mt_rand(100, 999999),
+        )
+      ),
+    );
+    $field_config = entity_create('field_config', $field);
+    $field_config->save();
+    $settings = $field_config->getSettings();
+    // The non-existent default image should not be saved.
+    $this->assertNull($settings['default_image']['fid']);
+
+    $field_instance_config = entity_create('field_instance_config', $instance);
+    $field_instance_config->save();
+    $settings = $field_instance_config->getSettings();
+    // The non-existent default image should not be saved.
+    $this->assertNull($settings['default_image']['fid']);
+
+  }
+
 }
