Problem/Motivation
This seems to be a regression of #2644468: Multiple image upload breaks image dimensions.
The patch in #33 also helps editors to translate image (media) entites when editing node content, if using https://www.drupal.org/project/media_library_edit module or with patch from #2985168: [PP-1] Allow media items to be edited in a modal when using the field widget.
Steps to reproduce
A translatable and moderated node type with an image field, that has the image field set to do property synchronization of the file/fid property (which internally includes width and title).
Trying to save a translation then results in "Non-translatable field elements can only be changed when updating the original language." and there is also a php notice: Message Notice: Undefined index: width in Drupal\content_translation\Plugin\Validation\Constraint\ContentTranslationSynchronizedFieldsConstraintValidator->hasSynchronizedPropertyChanges() (line 153...
Apparently width/height aren't set anymore in $items. I didn't yet investigate why that happens exactly, doesn't quite make sense to me yet, as it is a defined property, it should always be set?
Reverting #2644468: Multiple image upload breaks image dimensions fixes the problem.
Proposed resolution
- Changes setting image width and height from Drupal\image\Plugin\Field\FieldType\ImageItem::preSave()
into Drupal\image\Plugin\Field\FieldType\ImageItem::onChange()