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?

  • 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. – marcvangend Jul 27 '11 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. – Camsoft Jul 27 '11 at 16:14
  • 1
    Have you considered using field_view_value? – h0tw1r3 Jul 27 '11 at 17:43
1

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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.