drupal 7 中 在node.tpl.php 中显示图片的样式比较简单,只需要几段的代码就能实现。
<?php $image_uri = $node->field_image['und'][0]['file']['uri']; $image_url_with_style = image_style_url('square_thumbnail',$image_uri);//square_thumbnail是图片样式 echo '<img src="'.$image_url_with_style.'">'; ?>
如果字段类型为"Multimedia asset"(Media 模块的字段),而不是系统的“Image”,则要稍微改改代码
<?php $image_uri = $node->field_image_media['und'][0]['file']->uri; $image_url_with_style = image_style_url('square_thumbnail',$image_uri); echo '<img src="'.$image_url_with_style.'">'; ?>
评论
$image_uri = $node->field
应该是