Field values for new media entity references on node bundles are not getting populated
Here is the migration config I'm using:
field_image_media:
-
plugin: sub_process
source: field_thumbnail
process:
target_id:
-
plugin: migration_lookup
source: fid
migration: upgrade_d7_file
no_stub: true
-
plugin: update_file_to_image
When using the update_file_to_document plugin, this config works for creating new media entities and populating the node entity reference fields with the correct values. For image media, the field_image_media_target_id (for a field_image_media field) is always 1, which is obviously not correct.
I've gone over this a little in the #migration slack channel, and was happy to get the migration working for document (file) fields, but I haven't been able to get the image fields to migrate in the same way, which is why I'm opening an issue here, for some more visibility while I continue to debug my process.
Issue fork migrate_media_handler-3255716
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
srjoshare you sure that it's fid, and not target_id?
Comment #3
stephenplatz commentedChanging
source: fidtosource: target_iddoes not populate the field at all. Withfidthe field does get populated if I look in that table, but the values for the target id are wrong.Comment #4
stephenplatz commentedIt turns out this is because the transform method in the UpdateFileToImage plugin class is returning the entire $media object, and not just the $media->id(), which is what's needed for the target_id destination property. This was actually fixed in a previous commit, but it's not reflected in the latest release for some reason. I guess steps need to be taken to make sure that the latest packaged release has the most recent versioned code in it.
Comment #5
stephenplatz commentedComment #6
srjoshI'm going to be releasing the 2.1 version shortly; it will contain this fix and many others.
Comment #7
srjosh