1

In D7, I have an event content type containing an image field ("Featured image") and a file field ("Document"). I have a view of events containing documents, and would like to wrap a link around the image, leading to the document. Here's a sample link.

How can I rewrite the image (or use another technique) to get the desired link around the image? Looking at available tokens (I did add a second, hidden Document field above the image to define tokens), nothing seems suitable. Thanks for your help.

3
  • First add the "Content:File" field
  • Check "Exclude from display" (hidden)
  • Under "Formatter" select "URL to file"
  • Then add your Image field and uncheck "Link this field to the original piece of content" or something similar
  • Click on "Rewrite Results" and check "Output this field as a link"
  • In the "Link path" textbox add "Replacement Pattern" from the file field ([field_file] == Content: File, for example)
  • Thank you! I had used a similar method, but was rewriting the field output and it left me feeling dirty… I knew there was a more neutral way to tell Drupal about the link URL without interfering with its markup rendering. – UTAN_dev May 7 '16 at 12:20
0

You can simply write

['imag-tag']

in view select "Global custom" field.

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.