I am trying to output this image :

enter image description here

However, nothing gets printed out. My code is

print render($media_item->field_media_photo['und'][0]

Why doesn't it work?

有帮助吗?

解决方案

Use image_style_url instead.

$image_uri = $media_item->field_media_photo['und'][0]['uri'];
$image_stylePath = image_style_url("large", $image_uri);
print theme("image", array(
    'path' => $image_stylePath
));

其他提示

It wont work that way. Best way is to use theme function.

$image = theme('image', $vars);
$path = $media_item->field_media_photo['und'][0]['uri'];

$vars =  array(
  'path' => $path , 
  'alt' => 'alt',
  'attributes' => array('class' => 'example'),
  );

here only the path is mandatory. You can print the variable $image in a .tpl file and the image will appear.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top