diff --git a/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php
index 2dde5527..472aa0db 100644
--- a/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php
+++ b/core/modules/image/src/Plugin/Field/FieldWidget/ImageWidget.php
@@ -206,11 +206,37 @@ public static function process($element, FormStateInterface $form_state, $form)
         'uri' => $file->getFileUri(),
       ];
 
+      // Validate for svg file, return error or empty.
+      $svg_validate = file_validate_extensions($file, 'svg');
+
       // Determine image dimensions.
+      // Width and height from custom.
       if (isset($element['#value']['width']) && isset($element['#value']['height'])) {
         $variables['width'] = $element['#value']['width'];
         $variables['height'] = $element['#value']['height'];
       }
+      // Width and height from svg image.
+      elseif (empty($svg_validate)) {
+        // Set default width and height values.
+        $variables['width'] = $variables['height'] = 64;
+        $file_contents = file_get_contents($file->getFileUri());
+        // In some cases file could be not available for the loading. It could be
+        // deleted from the files folder physically, moved to other place or
+        // permissions will not allow to read it. In this case we will just skip
+        // dimensions discovering.
+        if ($file_contents) {
+          $svg = simplexml_load_string($file_contents);
+          $needed_variables = ['width', 'height'];
+          if ($svg) {
+            foreach ($svg->attributes() as $attribute => $value) {
+              if (in_array($attribute, $needed_variables)) {
+                $variables[$attribute] = (integer) $value;
+              }
+            }
+          }
+        }
+      }
+      // Width and height from upload image.
       else {
         $image = \Drupal::service('image.factory')->get($file->getFileUri());
         if ($image->isValid()) {
@@ -224,7 +250,7 @@ public static function process($element, FormStateInterface $form_state, $form)
 
       $element['preview'] = [
         '#weight' => -10,
-        '#theme' => 'image_style',
+        '#theme' => empty($svg_validate) ? 'image' : 'image_style',
         '#width' => $variables['width'],
         '#height' => $variables['height'],
         '#style_name' => $variables['style_name'],
@@ -245,10 +271,12 @@ public static function process($element, FormStateInterface $form_state, $form)
     elseif (!empty($element['#default_image'])) {
       $default_image = $element['#default_image'];
       $file = File::load($default_image['fid']);
+      // Validate for svg file, return error or empty.
+      $svg_validate = file_validate_extensions($file, 'svg');
       if (!empty($file)) {
         $element['preview'] = [
           '#weight' => -10,
-          '#theme' => 'image_style',
+          '#theme' => empty($svg_validate) ? 'image' : 'image_style',
           '#width' => $default_image['width'],
           '#height' => $default_image['height'],
           '#style_name' => $element['#preview_image_style'],
diff --git a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php
index d5cf58c5..aceb5b7f 100644
--- a/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php
+++ b/core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php
@@ -223,7 +223,9 @@ protected function load() {
    * {@inheritdoc}
    */
   public function isValid() {
-    return ((bool) $this->preLoadInfo || (bool) $this->resource);
+    $regex = '/\\.(' . preg_replace('/ +/', '|', preg_quote('svg')) . ')$/i';
+    $is_svg = preg_match($regex, $this->getSource());
+    return ((bool) $this->preLoadInfo || (bool) $this->resource || $is_svg);
   }
 
   /**
@@ -425,6 +427,8 @@ public static function getSupportedExtensions() {
         $extensions[] = 'jpe';
       }
     }
+    // Add svg extension.
+    $extensions[] = 'svg';
     return $extensions;
   }
 
