I would like to use features to import/export some content. The content type conains custom field of file, so I am using hook_uuid_node_features_export_render_alter(&$export, $node, $module){..} to add UUID of the file to the export.
function MODULE-NAME_uuid_node_features_export_render_alter(&$export, $node, $module){
if($module == 'MODULE-NAME'){
$field_instance = field_get_items('node', $node, 'field_elastic_slide');
foreach($field_instance as $key => $instance){
$file = file_load($instance['image']);
$export->field_elastic_slide['und'][$key]['image'] = (array)$file;
$file = file_load($instance['thumb_image']);
$export->field_elastic_slide['und'][$key]['thumb_image'] = (array)$file;
}
}
}
This works well and the UUID along the other file info is written into the file ending .features.uuid_node.inc part of the export module. So far, so good.
When importing, i would like to use the UUID to look up the FID of file on the Drupal instance import taking place, so i am using:
function MODULE-NAME_uuid_node_features_rebuild_alter(&$node, $module){
if($module == 'MODULE-NAME'){
$field_instance = field_get_items('node', $node, 'field_elastic_slide');
foreach($field_instance as $key => $instance){
$uuid = $instance['image']['uuid'];
// We have a uuid - we'll try to retrieve fid.
$file = entity_uuid_load('file',$uuid);//attempt 1
$slider_img = current($file);
$fid = uuid_get_serial_id('file', 'fid', $uuid); //attempt 2
// There is no local image.
if (empty($fid)) {
watchdog(WATCHDOG_NOTICE, 'Slider image with uuid: ' . $uuid.' was not found', WATCHDOG_ERROR);
}
$node->field_elastic_slide['und'][$key]['image'] = $fid;
...
This is not working. Where is the UUID<->FID Map stored for features? How to retrieve the FID at the time of importing(enabling the feature)? Any help is much appriciated