0

I used the following migration file to migrate user pictures from a Drupal 7 site installation to Drupal 8:

migrate_plus.migration.drupal7_image.yml

id: drupal7_image
label: Images
migration_group: dhm_migrate_taxonomy
migration_tags:
  - Drupal 7
source:
  plugin: d7_file
  constants:
    source_base_path: '/var/www/html/migrate_training_7/web/'
process:
  fid: fid
  filename: filename
  source_full_path:
    -
      plugin: concat
      delimiter: /
      source:
        - constants/source_base_path
        - filepath
    -
      plugin: urlencode
  uri:
    plugin: file_copy
    source:
      - '@source_full_path'
      - uri
  filemime: filemime
  status: status
  created: timestamp
  changed: timestamp
  uid: uid
destination:
  plugin: entity:file
migration_dependencies: {}

And I am using this next snippet to link the migrated image files to the user picture field (This is used in my user migration file):

migrate_plus.migration.custom_user.yml

  user_picture: # Image field name in Drupal 8 site
    plugin: iterator
    source: user_picture # Image field name in Drupal 7 site
    process:
      target_id: fid
      alt: alt
      title: title
      width: width
      height: height

migration_dependencies:
  required:
    - drupal7_image

I can see that the files are being migrated and downloaded to my Drupal 8 installation but when I check the users I don't see any user pictures (fields are blank).

I really don't know what I am missing, I searched for examples on the Internet but I didn't find much.

Any help would be much appreciated. Thanks in advance. ;)

  • 1
    Let try plugin migration_lookup to apply new fid for user picture value. – MrD Jan 29 at 10:34
1

Thanks a lot @MrD I tested using the migration_lookup plugin and it works like a charm:

  user_picture:
    -
      plugin: default_value
      source: picture
      default_value: null
    -
      plugin: migration_lookup
      migration: drupal7_image
  • Do we need to migrate files before the users or should the migration_lookup pull the pic in as the user migrates? – dibs Mar 28 at 0:23
  • I think you need to migrate the files first. I am not sure tbh. – Achraf JEDAY Mar 29 at 9:41

Your Answer

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

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