我有一段时间将图像从Wordpress迁移到Drupal迁移2.4模块。这里是我的映射:将Wordpress图像迁移到2.4迁移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_postmeta表中的结果返回给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_postmeta'表返回图像名称和相对路径,如'2012/05/figure1.jpg'。然后我用prepareRow()这样的:
function prepareRow($row) {
$row->images = $this->getImages($row);
}
我猜有时髦的东西与我如何使用处理该文件中的字段新十岁上下的迁移模块。 sql是正确输出文件名,但似乎并不像图像被复制过来。这是一个使用Migrate 2.4的Drupal 7。任何帮助表示赞赏。