I'm in the process of building a migration module for a d6 to d7 migration using the d2d module.

I'm almost there, but one thing that's holding me back is the DrupalPicture6Migration. After trial and error, this is what I have (using the d2d documentation):

/* Register the picture migration */

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

source_dir points to the correct location: /sites/default/files/userPictures.

I'd expect the migration to go like this:

'sites/default/files/userPictures/picture-1589309970.jpg  -> public://pictures/picture-1589309970.jpg.

But when I perform the migration, the path gets migrated over instead of the pictures. So I end up recieving this error:

'The specified file sites/default/files/userPictures/picture-1589309970.jpg could not be copied to public://pictures/sites/default/files/userPictures/picture-1589309970.jpg.

The entire path sites/default/files/userPictures/picture-xx.jpg is copied into the public://pictures directory.

I am reading up on using destination_file but am failing to make the connection on how I'd code this.


  • Did u get the answer to this question? because I am also in the same situation and need answer for this. Nov 27, 2013 at 9:41

1 Answer 1


You may try to specify the destination_dir in the __construct() instead of passing the arguments e.g.

class FooUserPictureMigration extends DrupalPicture6Migration {

  public function __construct(array $args) {

    // Add simple field mappings
    $this->addFieldMapping('source_dir', FALSE)
     $this->addFieldMapping('destination_dir', FALSE)

Where MIGRATE_D6_USERPIC_SRC_DIR is your source dir and MIGRATE_D6_USERPIC_DST_DIR is your destination dir (e.g. public://pictures).

Alternatively you can fix the user avatars by the following one-time query:

UPDATE users u
SET picture = (SELECT fid FROM file_managed fm WHERE filename = (SELECT SUBSTRING_INDEX(picture, '/', -1) as filename FROM DRUPAL6_DB.users as d6u WHERE name = u.name AND picture <> '' AND fm.filename = SUBSTRING_INDEX(picture, '/', -1)))
  WHERE u.name <> '' 
    AND u.name IN (SELECT name FROM DRUPAL6_DB.users WHERE picture <> '')

WHERE DRUPAL6_DB is your database name for Drupal 6.

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.