سؤال

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