When migrating nodes, if I assign a field like the default taxonomy (machine name 'tags') to the content type, this field becomes available as part of the migration destination (via the key 'field_tags'). If I assign that same field to the image file type (/admin/structure/file-types/manage/image/fields), it does not show?
I've looked over the documentation, and I don't really see anything regarding this issue.

Appreciate any guidance you can offer.

Comments

mikeryan’s picture

Project: Migrate » Migrate Extras
Component: Code » Media
Status: Active » Closed (duplicate)

To add fields to files/images, you need to be using the Media module, which is supported by the Migrate Extras module, not Migrate itself. To pick up the fields you need to specify the 'image' bundle as the argument to MigrateDestinationFile() - see http://drupal.org/node/1546120#comment-5981846.

Anonymous’s picture

I see. Correct me if I'm wrong, but isn't only one migration destination allowed per migration? That is to say, if I have both pdf documents and image files to migrate, at least two migrations are required with the suggested method?

I could not do something tricky like changing the destination on the fly, right? E.g.:

  public function prepareRow($current_row) {
    if($current_row->media_type === 'image'){ //assume media_type is correctly assigned from before
      $this->destination = new MigrateDestinationFile('image'); 
    }                                            
  }  
mikeryan’s picture

The cleanest thing to do is to have separate migrations, one with MigrateDestinationFile('image') and another with MigrateDestinationFile('default') (or whatever bundle you're using for the documents). But, you can get away with dynamically setting the fields you desire for each type. The admin UI, of course, is static - it only knows about the destination set in the constructor.