I have configured the module to create a thumbnail from the first page of the PDF.
However, how can I make the image link automatically to the PDF on the server?

Currently, I can only list the thumbnail and a link to the PDF below it. (See attached image)

CommentFileSizeAuthor
#9 pdf_to_image-linked_field.png25.81 KBdman
pdftoimage.JPG20.38 KBalexloganlee

Comments

joel_guesclin’s picture

Bizarrely, the module doesn't seem to do this automatically. I intend to post this as an enhancement request. In the meantime, there is one easy solution which is to use the Contemplate (Content Template) module. This allows you to rewrite the output. I had a very simple case with nothing but body text, the PDF file field, and the Image file field. So first you configure both fields to output the URL (ie one will output the URL of the PDF file, the other the URL of the image file), and then you create a content template like this:

<?php print $node->content['body']['#value'] ?>
<a href="<?php print $node->field_publication[0]['view'] ?>"><img src="<?php print $node->field_pdf_generated_image[0]['view'] ?>" /></a>

Of course the names of the CCK fields will probably be different in your case.

iantresman’s picture

This would be an obvious, and desirable feature. I just went into the image settings, and found that I could insert all kinds of links (generated via ImageCache) to other image sizes, but the one obvious omission, was a link to the original PDF!

dman’s picture

Something like his was added to the d7 2.x branch, but only by radically replacing the way that file fields was working, so that method was unsustainable.

If someone wants to have a try, we can look at a patch. But bear in mind, there is no intrinsic link between the file and the image saved in the database, they are just two attachments that happen to be on the same node. thus, when the time comes to render the image using the field renderer, it doesn't have a handle on the PDF file that you are looking for. It would be interesting to see if someone knows how to solve that from within the CCK field rendering API.

iantresman’s picture

Another workaround to joel_guesclin's post #1, I guess, would be to use Views, and to rewrite the field. But yes, it would be more elegant to have it incorporated into CCK. Perhaps a post in the CCK issues forum might bring forth some suggestions.

joel_guesclin’s picture

I agree, and I actually used the Views solution elsewhere on the site

joel_guesclin’s picture

According to this related post, getting this into the module is horrendously difficult, so despite it being less "clean" probably the best thing to do (or at any rate the easiest) is to create an override template for the node (in my case for example, this is a file called node-issue.tpl.php), which contains some code something like this:

<?php global $base_url; ?>
<a href="<?php print $base_url . '/' . $node->field_publication[0]['filepath'] ?>"><img src="<?php print $node->field_pdf_generated_image[0]['view'] ?>" /></a><br />
<?php print $node->content['body']['#value']; ?>
dman’s picture

Version: 6.x-2.0 » 7.x-3.x-dev
Issue summary: View changes

pushing to current dev as a feature request, still want to see this happen.

Alexxikon’s picture

I am not sure if the Image link to file module that I wrote could be useful to solve this problem, but it's worth giving it a try. The module allows you to automatically link any image field in a node to any file field (e.g. a PDF file) in the same node.

dman’s picture

Status: Active » Closed (works as designed)
StatusFileSize
new25.81 KB

I tried out image_link_to_file and it works just great. I fully endorse that as a working solution for use with this module. It's so easy to configure, it's silly.
I think it's better that that generic solution gets plugged onto this one, rather than this one trying to get too far into rendering settings etc. These are complementary.

Linked Field

Also does exactly this, and I love field_formatter_settings power even more than image_link_to_file simplicity, so *that* is a more flexible and fun way to do exactly this also.
Linked_field

  • dman committed 0836eb4 on 7.x-3.x
    [#1316796] Tidied up some token conflicts - do not complain about non-...