function image_legacy_field_convert_load in Image 7
Implement hook_field_convert_load().
File
- ./
image_legacy.field_convert.inc, line 314
Code
function image_legacy_field_convert_load(&$object) {
/*
notes:
- we only want _originals
- we can clean up and delete deriv files from both the disk AND the DB: derivs in D7 do not appear in the DB.
- we have to clean up our crap in the files table: fix hacky filenames! we can do this as we come to each image,
since there is a 1-1 correspondence with image nodes
query:
-
*/
// We have already deleted the derivative files: we get only originals here.
$result = db_query("SELECT * FROM {image} i LEFT JOIN {file_managed} f ON i.fid = f.fid WHERE i.nid = :nid AND i.image_size = '_original'", array(
':nid' => $object->nid,
));
foreach ($result as $record) {
//dsm($record);
// Load just the tids into a dummy property on the object, so the core API can do its work with FieldAPI
// cardinality and language and all that malarkey.
$object->images_image_original = $record->fid;
}
//dsm($object);
return;
//////////
// The code to load from {term_user} is gone, so we have to do it ourselves here.
// Assume that taxonomy has already been upgraded and so it's the new table name for that
$result = db_query("SELECT tu.*, ttd.vid FROM {term_user} tu LEFT JOIN {taxonomy_term_data} ttd ON tu.tid = ttd.tid WHERE tu.uid = :uid", array(
':uid' => $object->uid,
));
/*
$query = db_select('term_user', 'tu')
->fields('tu')
->fields('ttd')
->condition('tu.uid', $object->uid, '=');
$query->join('taxonomy_term_data', 'ttd', 'tu.tid = ttd.tid ');
$result = $query->execute();
// AAAAAAAAAAAAAAAAAAAAAAAARGH fail.
*/
foreach ($result as $record) {
//dsm($record);
// Load just the tids into a dummy property on the object, so the core API can do its work with FieldAPI
// cardinality and language and all that malarkey.
$object->{'term_user_' . $record->vid}[] = $record->tid;
}
}