diff -u b/core/modules/image/image.module b/core/modules/image/image.module --- b/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -422,7 +422,7 @@ $fid = $entity->settings['default_image']['fid']; if ($fid) { - $original_fid = isset($entity->original) ? $fid : NULL; + $original_fid = isset($entity->original) ? $entity->original->settings['default_image']['fid'] : NULL; if ($entity->settings['default_image']['fid'] != $original_fid) { $image = \Drupal::service('image.factory')->get(file_load($fid)->getFileUri()); $entity->settings['default_image']['width'] = $image->getWidth(); only in patch2: unchanged: --- a/core/modules/image/lib/Drupal/image/Plugin/Field/FieldType/ImageItem.php +++ b/core/modules/image/lib/Drupal/image/Plugin/Field/FieldType/ImageItem.php @@ -335,6 +335,7 @@ protected function defaultImageForm(array &$element, array $settings) { '#description' => t('Image to be shown if no image is uploaded.'), '#default_value' => empty($settings['default_image']['fid']) ? array() : array($settings['default_image']['fid']), '#upload_location' => $settings['uri_scheme'] . '://default_images/', + '#element_validate' => array(array($this, 'validateDefaultImageForm')), ); $element['default_image']['alt'] = array( '#type' => 'textfield', @@ -361,6 +362,34 @@ protected function defaultImageForm(array &$element, array $settings) { } /** + * Validates the managed_file element for the default Image form. + * + * This function ensures the fid is a scalar value and not an array. It is + * assigned as a #element_validate callback in + * \Drupal\image\Plugin\Field\FieldType\ImageItem::defaultImageForm(). + * + * @param array $element + * The form element to process. + * @param array $form_state + * The form state. + */ + public function validateDefaultImageForm(array &$element, array &$form_state) { + // Call the original validator to ensure referencing an existing file is + // only allowed if there are existing references. + file_managed_file_validate($element, $form_state); + + // Consolidate the array value of this field to a single FID as #extended + // for default image is not TRUE and this is a single value. + if (isset($element['fids']['#value'][0])) { + $value = $element['fids']['#value'][0]; + } + else { + $value = 0; + } + \Drupal::formBuilder()->setValue($element, $value, $form_state); + } + + /** * {@inheritdoc} */ public function isDisplayed() {