diff --git a/core/modules/file/lib/Drupal/file/Plugin/field/field_type/FileField.php b/core/modules/file/lib/Drupal/file/Plugin/field/field_type/FileField.php index 55bef1f..56b95df 100644 --- a/core/modules/file/lib/Drupal/file/Plugin/field/field_type/FileField.php +++ b/core/modules/file/lib/Drupal/file/Plugin/field/field_type/FileField.php @@ -51,13 +51,12 @@ protected function updateFileUsage() { // Compare the original field values with the ones that are being saved. $field_name = $this->getFieldDefinition()->getFieldName(); $original_fids = array(); - if (!empty($entity->original->$field_name)) { - foreach ($entity->original->$field_name as $item) { - $original_fids[] = $item->target_id; - if (isset($item->target_id) && !in_array($item->target_id, $fids)) { - // Decrement the file usage count by 1. - file_usage()->delete($item->entity, 'file', $entity->entityType(), $entity->id()); - } + $original_items = $entity->original->getTranstaltion($this->getLangcode())->$field_name: + foreach ($original_items as $item) { + $original_fids[] = $item->target_id; + if (isset($item->target_id) && !in_array($item->target_id, $fids)) { + // Decrement the file usage count by 1. + file_usage()->delete($item->entity, 'file', $entity->entityType(), $entity->id()); } } diff --git a/core/modules/image/lib/Drupal/image/Plugin/field/field_type/ImageItem.php b/core/modules/image/lib/Drupal/image/Plugin/field/field_type/ImageItem.php index 2bb8236..a6d8972 100644 --- a/core/modules/image/lib/Drupal/image/Plugin/field/field_type/ImageItem.php +++ b/core/modules/image/lib/Drupal/image/Plugin/field/field_type/ImageItem.php @@ -287,16 +287,15 @@ public function instanceSettingsForm(array $form, array &$form_state) { * {@inheritdoc} */ public function preSave() { - $width = $this->get('width')->getValue(); - $height = $this->get('height')->getValue(); + $width = $this->width; + $height = $this->height; // Determine the dimensions if necessary. if (empty($width) || empty($height)) { $image = \Drupal::service('image.factory')->get($this->entity->getFileUri()); - if ($image->getExtension()) { - $this->set('width', $image->getWidth()); - $this->set('height', $image->getHeight()); + $this->width = $image->getWidth(); + $this->height =$image->getHeight(); } } }