Good idea to add this function into module core that to not add it in each module, that loads files.

function _load_file($fid) {
    $file = db_fetch_object(db_query("SELECT * FROM {files} WHERE fid = %d", $fid));
    return $file;
}

I couldn't find it in drupal core :(

Comments

alan d.’s picture

Status: Active » Closed (works as designed)

Hi Electronick

I think that having a one-liner function is not overly helpful in the module, reopen if anyone thinks otherwise.

When I get a chunk of free time, I'm going to look at refactoring things a bit, namely cleaner field processing and allowing either the file object or {files}.fid to be passed as the elements default value. This would eliminate the need to even load the files record at all.

I must admit that I searched for exactly the same function while doing the module, and had even included a similar function back then, before dropping it. ;)

Alan

Electronick’s picture

> {files}.fid to be passed as the elements default value
Alan, i think, if you do it, you can pass ['#tree'] problem.