0

I'm trying to create a translation on a node's paragraph field whose paragraph contains a text field and an image field. The code below updates the text field as expected but the image field is always blank/empty for the translated node:

<?php
   $img[] = array(
            'target_id' => 1029,
            'alt' => 'Translated alt tag',
            'title' => '',
        );
        $desc1[] = array(
            'value' => 'Translated Text',
            'summary' => '',
            'format' => 'basic_html',
        );
        $lang_node->field_images_descriptions->entity
            ->addTranslation($lang_code, [
                'field_product_image' => $img,
                'field_product_description' => $desc1,
            ])
            ->save();

enter image description here

2
  • Looks like you set $img then try to access $img1 later. – sonfd Feb 15 at 19:12
  • Thank you sonfd, that was just a typo in my sample code but my actual code uses the same $variable. I've fixed my question's code. – quantumized Feb 15 at 19:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.