Picture migration

Last updated on
30 April 2025

You are browsing documentation for an older version of Drupal, which is not supported any longer, and the information may not be correct. See current documentation for Contributed modules

A special case of file migrations, this is used to migrate user pictures if any. With a Drupal 7 source, user pictures are stored in the file_managed table like other files, but earlier Drupal versions simply stored filespecs in the users table. The user_migration argument should not be used here, because pictures should be migrated before users. To handle the chicken-and-egg problem (users reference the picture file IDs, while the file_managed rows reference the owning users), we migrate the pictures first with a default UID, then when we migrate the users we update the picture data with the uid of the newly-created user account.

$picture_arguments = $common_arguments + array(
  'machine_name' => 'ExamplePicture',
  'description' => t('Import Drupal 6 picture files'),
  'default_uid' => 1,
  'source_dir' => '/path/to/files',
  'destination_dir' => 'public://pictures',
);
Migration::registerMigration('DrupalPicture6Migration', 
  $picture_arguments['machine_name'], $picture_arguments);

Help improve this page

Page status: Not set

You can: