Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I have a field which allows a user to upload 3 photos called field_prodshots. To any Views experts out there, is it possible to display just the first value of that field instead of all 3 while using "Rewrite the output of this field" tokens? After all, I only need the one image to use as a thumbnail.

Typing in [field_prodshots] in the textarea for rewriting the output results in the display of all 3 images. I only need the first one.

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

There's a simple way to show only the first image in a field that allows multiple image uploads.

In the Configuration screen for the field, there's a dropdown called "Multiple Field Settings." Expand that, and you should see options for how many items you want to display, and which item in the list to start with. Change "Display __ value(s)" from all to 1. You shouldn't need to change the separator in your case, as you're only displaying one image.

See below for screenshot. This setting should work fine alongside "Rewrite the output of this field" tokens (I haven't had it not work).

In a field with several images uploaded, I'm correctly seeing only the first as you can see here:

share|improve this answer
    
This was a great reply! I really appreciate the image too. This saved it for me. Thanks! –  enchance Jun 9 '11 at 19:13
    
Thanks, glad it worked for you! –  g_thom Jun 11 '11 at 2:11
add comment

Create a template file in your currently active theme's folder

e.g. views-view-field--field-my-field-value.tpl.php

print_r(array_keys(get_defined_vars())) to get full list of scope variables. The most usable will be $fields and $view

share|improve this answer
    
I didn't know there was such a thing as Views templates. Now things get interesting. –  enchance Jun 9 '11 at 19:13
add comment

If there are no other fields in the view, you can filter it by that field's delta 0.

Haven't tested it, but in Filter Criteria selecting Fields: ... (field_prodshots) - delta and setting that to 0 should give only the first value.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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