四步:
- 先用node_load 函数读出节点内容
- 然后把节点中的图片字段,通过field_get_items 获取,
- 再把获取的值通过field_view_value转换,
- 最后是通过render 转换成图片html
1 2 3 4 5 6 7 8 9 | <?php $node = node_load( $nid ); $image = field_get_items( 'node' , $node , 'field_NAME' ); foreach ( $image as $key => $value ) { $output = field_view_value( 'node' , $node , 'field_NAME' , $image [ $key ] )); print render( $output ); } ?> |
如果需要更详细的定制,可以改为下面代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <?php $node = node_load( $nid ); $image = field_get_items( 'node' , $node , 'field_NAME' ); foreach ( $image as $key => $value ) { $output = field_view_value( 'node' , $node , 'field_NAME' , $image [ $key ], array ( 'type' => 'image' , 'settings' => array ( 'image_style' => 'thumbnail' , //place your image style here 'image_link' => 'content' , ), )); print render( $output ); } ?> |