Image 使用Migrate 2.4将Wordpress图像迁移到Drupal

Image 使用Migrate 2.4将Wordpress图像迁移到Drupal,image,wordpress,drupal,migrate,Image,Wordpress,Drupal,Migrate,我正在使用Migrate2.4模块将图像从Wordpress迁移到Drupal。以下是我的映射: $this->addFieldMapping('field_image','images'); $this->addFieldMapping('destination_file', 'images'); $this->addFieldMapping('field_image:source_dir') ->defaultValue('/Users/grafa/htdocs/w

我正在使用Migrate2.4模块将图像从Wordpress迁移到Drupal。以下是我的映射:

$this->addFieldMapping('field_image','images');
$this->addFieldMapping('destination_file', 'images');
$this->addFieldMapping('field_image:source_dir')
 ->defaultValue('/Users/grafa/htdocs/wordpress/wp-content/uploads');
$this->addFieldMapping('field_image:file_class')
  ->defaultValue('MigrateFileUri');
图像来自一个查询wp_postETA表的函数,然后将结果返回给prepareRow()函数

function getImages($row) {
$post_id = $row->id;
$results = db_query("
  SELECT pm.post_id, pm.meta_key, pm.meta_value FROM streetroots_wp.wp_postmeta AS pm LEFT JOIN streetroots_wp.wp_posts AS p ON pm.post_id=p.id WHERE p.post_parent = $post_id AND pm.meta_key='_wp_attached_file';");

$images = array();
foreach($results as $result) {
  $images[] = $result->meta_value;
}
return !empty($images) ? $images : NULL;
}
这基本上是从wp_Posteta表返回图像名称和相对路径,类似于'2012/05/figure1.jpg'。然后我使用prepareRow()如下所示:

 function prepareRow($row) {
$row->images = $this->getImages($row);
}

我猜我使用新的ish migrate模块处理文件字段的方式有些古怪。sql是正确输出文件名的,但似乎没有复制图像。这是一个使用Migrate2.4的Drupal7。感谢您的帮助

您可能希望查看migrate_example文件夹中的beer.inc行377-383,以及相关的内容类型*migrate_example_beer*,其中定义了一个图像字段,而不是一个文件字段,这是我的错误,导致我的图像无法填充


希望这有帮助

您可能希望查看migrate_example文件夹中的beer.inc行377-383,以及相关的内容类型*migrate_example_beer*,其中定义了一个图像字段,而不是一个文件字段,这是我的错误,导致我的图像无法填充


希望这有帮助

Migrate 2.5大大简化了文件的处理,您应该查看一下

Migrate 2.5大大简化了文件的处理,您应该查看一下