diff --git a/core/modules/file/file.module b/core/modules/file/file.module index 56bafe0..7f9ec9f 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -414,7 +414,8 @@ function file_validate_is_image(File $file) { $image = \Drupal::service('image.factory')->get($file->getFileUri()); if (!$image->isSupported()) { - $toolkit = \Drupal::service('image.toolkit'); + $toolkit_manager = \Drupal::service('image.toolkit.manager'); + $toolkit = $toolkit_manager->createInstance($toolkit_manager->getDefaultToolkitId()); $extensions = array(); foreach ($toolkit->supportedTypes() as $image_type) { $extensions[] = Unicode::strtoupper(image_type_to_extension($image_type)); diff --git a/core/modules/file/lib/Drupal/file/Tests/ValidatorTest.php b/core/modules/file/lib/Drupal/file/Tests/ValidatorTest.php index cfde9a3..4258a56 100644 --- a/core/modules/file/lib/Drupal/file/Tests/ValidatorTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/ValidatorTest.php @@ -79,7 +79,7 @@ function testFileValidateImageResolution() { $this->assertEqual(count($errors), 1, 'Small images report an error.', 'File'); // Maximum size. - if ($this->container->has('image.toolkit')) { + if ($toolkit_id = $this->container->get('image.toolkit.manager')->getDefaultToolkitId()) { // Copy the image so that the original doesn't get resized. copy('core/misc/druplicon.png', 'temporary://druplicon.png'); $this->image->setFileUri('temporary://druplicon.png'); @@ -87,7 +87,7 @@ function testFileValidateImageResolution() { $errors = file_validate_image_resolution($this->image, '10x5'); $this->assertEqual(count($errors), 0, 'No errors should be reported when an oversized image can be scaled down.', 'File'); - $image = $this->container->get('image.factory')->get($this->image->getFileUri()); + $image = $this->container->get('image.factory')->setToolkitId($toolkit_id)->get($this->image->getFileUri()); $this->assertTrue($image->getWidth() <= 10, 'Image scaled to correct width.', 'File'); $this->assertTrue($image->getHeight() <= 5, 'Image scaled to correct height.', 'File'); diff --git a/core/modules/image/image.install b/core/modules/image/image.install index 2b838e6..a1f3970 100644 --- a/core/modules/image/image.install +++ b/core/modules/image/image.install @@ -259,6 +259,10 @@ function image_update_8002() { * array by adding alt, title, width, and height options. */ function image_update_8003() { + $config = \Drupal::config('system.image'); + if (!$config->get('toolkit')) { + $config->set('toolkit', 'gd'); + } $image_factory = \Drupal::service('image.factory'); foreach (array('field', 'instance') as $type) { $prefix = "field.$type"; diff --git a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/GDToolkit.php b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/GDToolkit.php index 8290369..8c58a36 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/GDToolkit.php +++ b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/GDToolkit.php @@ -295,7 +295,9 @@ public function getInfo(ImageInterface $image) { ); } - $this->load($image->getSource(), $details); + if ($details) { + $this->load($image->getSource(), $details); + } return $details; } diff --git a/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/TestToolkit.php b/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/TestToolkit.php index 29196fc..cf58c8a 100644 --- a/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/TestToolkit.php +++ b/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/TestToolkit.php @@ -57,7 +57,9 @@ public function getInfo(ImageInterface $image) { ); } - $this->load($image->getSource(), $details); + if ($details) { + $this->load($image->getSource(), $details); + } return $details; }