使用实用的预定义图像预设打印图像

时间:2013-01-17 07:13:09

标签: php image drupal drupal-7 drupal-theming

我只需要在Drupal 7中通过php打印出一个图像。我已经有3个预设,thumnail,中等和大。有没有人知道我需要打印出来的确切代码,因为我似乎无法解决这个问题?

据我所知,在Drupal 6中它是这样的:

<img src="<?php print 'sites/default/files/imagecache/**thumbnail**/' . $node->field_image_cache['0']['filepath']; ?>" />

我非常感谢任何帮助。

1 个答案:

答案 0 :(得分:2)

使用theme_image_formatter

E.g。

print theme("image_formatter", array(
    'image_style' => 'thumbnail',
    'item' => array(
        'uri' => 'sites/default/files/image.jpg',
        'alt' => t(""),
        'title' => t(""),
        'attributes' => array(),
    ),
));