1

I'm using field_view_field() to get the render array for a image field that has multiple values. I then use drupal_render() on that resulting array to print out the markup.

I only want the first image to be returned in the markup for that field. Is there a way to either manipulate the rendered array to remove the other fields or a setting when call field_view_field() to say only return first row?

3
  • Can you print_r() the return value of your field_view_field() call and add that to your post? That will make it easier to help you. Commented Jul 27, 2011 at 12:07
  • Can't really post all the code from that field_view_field() call as it's huge and includes the entire node array too. But you can replicate it by creating an image field with multiple instances enabled and then call the field_view_field() function from a custom module. Commented Jul 27, 2011 at 16:14
  • 1
    Have you considered using field_view_value? Commented Jul 27, 2011 at 17:43

1 Answer 1

1

Have you considered using field_view_value? It is the recommended way to retrieve a single value from a multi-value field.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.