diff --git a/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php index dd1510f..b329f04 100644 --- a/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php +++ b/core/modules/image/src/Plugin/Field/FieldType/ImageItem.php @@ -3,13 +3,13 @@ namespace Drupal\image\Plugin\Field\FieldType; use Drupal\Component\Utility\Random; +use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\StreamWrapper\StreamWrapperInterface; use Drupal\Core\TypedData\DataDefinition; use Drupal\file\Entity\File; -use Drupal\file\FileInterface; use Drupal\file\Plugin\Field\FieldType\FileItem; /** @@ -314,7 +314,7 @@ public function preSave() { $height = $this->height; // Determine the dimensions if necessary. - if (!$this->isEmpty()) { + if ($this->entity && $this->entity instanceof EntityInterface) { if (empty($width) || empty($height)) { $image = \Drupal::service('image.factory')->get($this->entity->getFileUri()); if ($image->isValid()) {