开发者

Drupal - displaying image in theme template from iids value only

I'm trying to theme one of my content types, which has images uploaded to each instance using the image attach module.

Using the deve开发者_如何学编程loper module, I've found the iids value of the uploaded image (eg 305), but i'm having trouble finding out how I can actually display the image in my code. This line outputs the node id of the image which has been uploaded, but how can I then use that?

$image = $node->iids[0];

I've tried using hook_image, but I can't seem to get that working...

Thanks for any help.


This did the trick...

$nodeid = $node->nid;
$get_image = db_query('
    SELECT p.filepath as imagefilename
    FROM {image_attach} i 
    LEFT JOIN {image} a ON i.iid = a.nid 
    LEFT JOIN {files} p ON a.fid = p.fid 
    WHERE i.nid = %d AND p.filename = "recipe_thumb"', $nodeid);
$obj_image = db_fetch_object($get_image);
$imagefilename = $obj_image->imagefilename;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜