I have a content type with an image field and a file field, being outputted in views. How do I want the image to link to the file.

How do I approach this? Make a template for the image field? And if so, how do I get the file field link from that template?

I'm using Drupal 7.


There are several ways to achieve this. I think the following one may be one of the easiest:

Assuming you have two fields outputted in views: "Image" and "File" make sure to display them in the following order:

  1. Image
  2. File

    1. Edit image field and mark "exclude from display"
    2. Edit file field and mark "rewrite output".
    3. You'll see you can use the image field as replacement patterns so you can print the previous field [image] and link it to the file by writing a bit of html code such as this one: <a href="[file]">[image]</a>.
| improve this answer | |
  • glad to be useful – ccamara Feb 19 '12 at 22:29

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.