Determines where a file is used.
$file: A file object.
A nested array with usage data. The first level is keyed by module name, the second by object type and the third by the object id. The value of the third level contains the usage count.
function file_usage_list(stdClass $file) {
$result = db_select('file_usage', 'f')
->fields('f', array(
'module',
'type',
'id',
'count',
))
->condition('fid', $file->fid)
->condition('count', 0, '>')
->execute();
$references = array();
foreach ($result as $usage) {
$references[$usage->module][$usage->type][$usage->id] = $usage->count;
}
return $references;
}