How to use same source media in 2 process fields

Created on 16 January 2025, 5 days ago

Hi all, I need your help.
I try to migrate external JSON to a Drupal content type.
I that content type, I have a background media image and a teaser media image.
Both should come from the same source record.
I want to avoid duplicate media items - so I look for a way to reuse the media defined for background media image also as teaser media image.
I thought I could just use '@field_background_image' as source - which does not work.

process:
  # create new media file and add mid to node field
  field_background_image:
    - plugin: skip_on_empty
      method: process
      source: '@_titlebackground_file'
    - plugin: create_media_from_uri
      file_options:
        filename: titlebackground
        status: '@_status'
        uid: '@_uid'
      media_options:
        name: '@_titlebackground_name'
        bundle: 'image'
        status: '@_status'
        uid: '@_uid'
        field_image/alt: '@_titlebackground_name'
  field_teaser_media:
    - plugin: skip_on_empty
      method: process
      source: '@field_background_image'

Should this work or is there an other way to do something like migration_lookup within the same migration?

💬 Support request
Status

Active

Version

6.0

Component

Documentation

Created by

🇩🇪Germany vistree

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024