4

I have a challenge in linking my image to a pdf file. I have a content type with 2 fields, image field which will contain the cover picture and an attachment field which is file of type pdf.

In my view am trying to link an image to attachment so that when a user clicks on the image it open a pdf file.

In some instances where am just using description to link to a pdf file, this what I have put in my Global PHP(Description) output code in my view. nid, 'filename.pdf'); ?> As soon as click on the description my pdf opens. works fine

But I need to do the same thing with my image, to just click on image then should open my pdf file. Any idea???

5

Hope this will help you,

In Drupal 7 you can use VIEWS Rewrite results to link an IMAGE to a PDF file.

Steps:

  • In PDF field, exclude it and change the format to "URL of file"

    enter image description here

  • Go to your VIEW -> Image field and under Link image to select NOTHING

  • And then go to Rewrite results and check Output this field as a link and give the path of the PDF file.

    enter image description here

    enter image description here

  • You can also use TOKENS by using Replacement patterns for PDF file path name

    enter image description here

  • Your welcome.. enjoy :) – inizio Aug 1 '13 at 6:33
  • Be sure you have your PDF field arranged first in the list followed by your imagefield, otherwise the image will not know what to link to. – user23803 Nov 19 '13 at 7:01
  • I took me a bit to realize -- it is a way down in the dialoge in a collapsed "replacement pattern menue" --- that the possible replacement are directly suggested for the page in questions, as in the example above. So you can "copy and paste" In contrast to drupal 7, in drupal 8 the fields have the format {{ field_file_u_upload }} == Content: File u upload – Max Mar 17 '17 at 9:50
1

You may want to try the Image link to file module, which I developed because I had the same problem. The module is very small and very simple to use. It is stable, even though it's an alpha release.

Hope this helps

—Alex

-2

You can go to your view>Click on the fild name(image) >After you select from list Link image to the option File.

And that's it.

  • it is exactly what am doing but its just opens the cover page instead of the whole pdf file. – Tebogo Jul 31 '13 at 12:38

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.