I have my files migrated from D7 to D8 (using d7_file source plugin to an entity:file destination).

I then migrated those files to media (using file_entity source plugin to an entity:media destination), based off this post.

However, the images in my Drupal 7 nodes of which I'm migrating never had alt text. Therefore, I would like to use the Drupal 7 node title as both (a) the Media title and (b) its image alt text.

My files to media migration looks like this (a portion of it):

  plugin: file_entity
  type: image
    bundle: 'image'
  mid: fid
  bundle: 'constants/bundle'
    plugin: default_value
    source: language
    default_value: "und"
  # name: filename
    plugin: default_value
    default_value: 1
  status: status
  created: timestamp
  changed: timestamp
  field_media_image/target_id: fid
  # field_media_image/alt: field_file_image_alt_text/0/value
  plugin: entity:media

The commented out lines are what I'd like to use the node title (name and field_media_image/alt), but I'm not sure how to pull in the original Drupal 7 node title. Any suggestions are appreciated.

1 Answer 1


Without knowing your content model, you can't answer this question directly, but what you'll need to do is query your node title for every fid entry for your source file entities table. You can do that in many places (e.g. source/process plugin) with your existing source plugin being a good place.

Using your custom file_entity source plugin as an example, you'll need to update the query() method so its DB query joins the node table based on how you're content is modeled (e.g. entity/paragraph references) then selects the title column so it's included in the row data. You can follow that up with updating the fields() method so your source plugin will provide the title field you need.

  • Thanks. Seems like modifying my source plugin is the best option, but a bit over my head. My D7 node type is Business with an image field_logo. I'm using Image media in D8 (with field_media_image). I'll do some research from here. Thanks again.
    – MrPeanut
    Mar 28, 2019 at 12:38
  • Is that essentially what this source plugin is doing? github.com/geerlingguy/drupal-8-example-pix_migrate/blob/master/…
    – MrPeanut
    Mar 28, 2019 at 13:21
  • It's roughly similar in that it's joining 2 tables to provide one set of migration fields. In your case, you're starting with the file_managed table (to pull in all files) then attaching other tables to find associated node data.
    – Shawn Conn
    Mar 28, 2019 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.