使用drupal7返回的图像路径


using image path returned by drupal 7

am无法使用drupal 7为自定义内容类型上传的图像返回的路径。返回的路径如下:

Array ( [und] => Array ( [0] => Array ( [fid] => 6 [alt] => [title] => [width] => 464 [height] => 261 [uid] => 1 [filename] => _71135631_c0166859-snotty_child_with_a_cold-spl.jpg [uri] => public://_71135631_c0166859-snotty_child_with_a_cold-spl.jpg [filemime] => image/jpeg [filesize] => 22168 [status] => 1 [timestamp] => 1384797114 [rdf_mapping] => Array ( ) ) ) )

但是当使用uri的vale时,没有显示图像。

感谢任何协助。

问候,a.ali

Drupal中这样的uri-字段总是指内部数据存储逻辑,因此一开始就是public://。Drupal对附加到内容的任何图像使用图像样式。

要检索图像的完整URL,您应该使用image_style_url():

$imgPath = image_style_url('default', $object['und'][0]['uri']);