diff --git a/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php
index 04ed6b6d..82092e6 100644
--- a/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php
+++ b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php
@@ -170,13 +170,19 @@ public static function process($element, FormStateInterface $form_state, $form)
       );
 
       // Determine image dimensions.
-      $image = \Drupal::service('image.factory')->get($file->getFileUri());
-      if ($image->isValid()) {
-        $variables['width'] = $image->getWidth();
-        $variables['height'] = $image->getHeight();
+      if (isset($element['#value']['width']) && isset($element['#value']['height'])) {
+        $variables['width'] = $element['#value']['width'];
+        $variables['height'] = $element['#value']['height'];
       }
       else {
-        $variables['width'] = $variables['height'] = NULL;
+        $image = \Drupal::service('image.factory')->get($file->getFileUri());
+        if ($image->isValid()) {
+          $variables['width'] = $image->getWidth();
+          $variables['height'] = $image->getHeight();
+        }
+        else {
+          $variables['width'] = $variables['height'] = NULL;
+        }
       }
 
       $element['preview'] = array(
