The context: drupal 7, views, views PHP, rendering some fields with PHP because there's no other way.
$nodo = node_load($row->nid); $strmn = '<div class="post-block">'; $strmn .= '<div class="post-image">'; $image = field_get_items('node', $nodo, 'field_image'); $preout= field_view_value('node', $nodo, 'field_image', $image); $linko= url('node/'. $nodo->nid); $strmn .= '<a href="' . $linko . '">' . render($preout) . '</a>';
After a lot of googling I've been able to write this.
It's very probably crude but it works, except I can't find a proper way to set height and width for the image. I don't want to create a style in drupal, it would be no good as it won't be used anywhere else. I also don't want, if at all possible, to rework my code to do something like:
$image = theme('image_style',array( 'style_name' => 'mail_image_big', 'path' => $image_obj['uri'], 'attributes' => array('style' => 'border:1px solid #aaa;') ) );
Because my php is sketchy at best and the knowledge of the drupal API is null. Every change costs me a lot of time and energy because, honestly, I lack the basics and I'm not sure of what I'm doing until I do it right.
Finally: how do I set the $display array in field_view_value so that height and width are set the way I want them in my output html? I can't find an example or a list of valid properties I can set in the $settings array to save my life. :)