in a script I would like to select (db-call) the filepath, does anybody has an example how to do this?

Thank you!

Comments

stoltoguzzi’s picture

I made it this way, I'm shure there is an bether way:-)

img_node is my current node

...</
$fid = db_fetch_object(db_query("SELECT f.field_bilder_fid  FROM {content_field_bilder} f WHERE nid = %d", $img_node->nid));
$img_path = db_fetch_object(db_query("SELECT f.filepath  FROM {files} f WHERE fid = %d", $fid->field_bilder_fid));
$img_path = 'src="' . file_create_url($img_path->filepath) . '"';
quicksketch’s picture

Status: Active » Fixed

You could also just look in $node->field_image[0]['filepath'], where "field_image" is the name of your ImageField. However if you're doing a database query and the node is not available, yes the approach you've used is fine.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

giorgio79’s picture

Was just looking for how to output an image based on the fid thank you.