Remove link from thumbnail image for pdf

When a pdf item record’s thumbnail is clicked, the default behavior is to open a window with options to open the pdf file with Adobe Reader or to download and save the file OR to automatically download and open the pdf, depending on the browser. Instead, I want site users to simply view the keyword-searchable pdf document in the Universal Viewer (or Docs Viewer) plugin area on the item show page. (If they want to save the pdf, they can initiate a download from there.)

I do want the thumbnail image to display, but want to prevent the pdf download from a simple left-click. I would be fine with breaking the thumbnail’s link, although I am open to other ideas.

Can anyone help me with code to remove the thumbnail link from items with pdf files?

Is there a better solution out there?

Thanks in advance!

As long as you’re not using the “gallery” option for your theme, using something like the PDF Embed plugin would replace the thumbnail with an embedded viewer for the PDF, which might work better for what you’re asking for.

Otherwise you’d be looking at editing the items/show theme code and iterating though each file, checking to see if it’s a PDF and then deciding what to display.

What I am hoping for is some code that I can add to the items/show.php file to remove the link from the thumbnail image for text files only. Pdf’s are the main target, but it would not go amiss to apply it to all text files. We currently use Docs Viewer (and are looking at moving to Universal Viewer).

I have customized a version of that file to suppress thumbnail display for the ‘person’ type of item, so I would think displaying the thumbnail as an unlinked image should be doable. Is it?

Thank you!

The metadata function can get you the URL for a file’s thumbnail, and you can easily use that to just create an <img> tag to show the thumbnail without any link wrapping around it.

The metadata call would be

metadata($file, 'thumbnail_uri');

If you’re not already, you’d probably need to loop through the files for the current item to get that $file object.