5

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.

5

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).

http://img585.imageshack.us/img585/8644/multipleimagesshowonlyo.png

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

http://img713.imageshack.us/img713/5479/resultzc.png

  • This was a great reply! I really appreciate the image too. This saved it for me. Thanks! – enchance Jun 9 '11 at 19:13
2

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

  • I didn't know there was such a thing as Views templates. Now things get interesting. – enchance Jun 9 '11 at 19:13
2

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.

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.