How can I attach an image from an existing image field to another multi-value image field? I have the nodes that have the source image field field_old_image_field and the destination image field, field_new_image_field. field_old_image_fieldhas only one image. field_new_image_fieldcan have multiple images and probably does. I need to copy the image from field_old_image_field to field_new_image_field without disturbing the images that are already in field_new_image_field.
Here's my code so far:
foreach ($nodes as $node) {  
    if ($node-&gt;hasField('field_old_image_field') &amp;&amp; !empty($node-&gt;field_old_image_field-&gt;target_id)) {
      $image = $node-&gt;get('field_old_image_field');
      $image_uri = $image-&gt;entity-&gt;getFileUri();
      $image_alt = $image[0]-&gt;get('alt')-&gt;getString();
      $image_title = $image[0]-&gt;get('title')-&gt;getString();

      $node-&gt;get('field_new_image_field')-&gt;appendItem([
        'target_id' =&gt; $image,
        'alt' =&gt; $image_alt,
        'title' =&gt; $image_title,
      ]);
    }

    $node-&gt;save();
  }

But when I run this code in an update hook, I get
In EntityReference.php line 106:

Value is not a valid entity.

I was getting it to work earlier, but I wasn't getting the alt text or the title text copied over. What's wrong with this code and is there an easier way to do this?
The first line doesn't get you an image, it's a field item list:
$items = $node-&gt;get('field_old_image_field');

Then you can get the first item
$item = $items[0];

and append the item properties to the new field:
$node-&gt;get('field_new_image_field')-&gt;appendItem([
  'target_id' =&gt; $item-&gt;target_id,
  'alt' =&gt; $item-&gt;alt,
  'title' =&gt; $item-&gt;title,
]);