Support » Plugin: PDF Thumbnails » Gallery with thumbnails linking to PDF files

  • Resolved joschi81


    Hi stianlik,

    great plugin, thanks for your work.

    I was wondering if it’s actually possible to create a gallery with PDF thumbnails where each thumbnail links to the respective PDF file. Do you already have a good solution for this?

    So far, I used a quite “dirty” JS/jQuery workaround:

    var $ = jQuery;
      if($('.pdf-archive').length) {
          var url = $(this).find('a').attr('href');
          var newurl = url.replace('-pdf-image.jpg','.pdf');

    I place a <div> with a “pdf-archive” class somewhere on the page to show that it’s a PDF archive. If an element with this class exists, I manipulate all the gallery item links so that they link to the respective PDF file.

    However, in my point of view the best way to do this would be a third option within the gallery settings for the gallery link: “PDF file”. And if no PDF file exists for one of the gallery items, media file or attachment page can be set as a fallback.

    What do you think? Would that be complicated to implement?

    Best regards

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author stianlik


    After reading the post one more time, I see that you are adding the images and linking to PDFs, which seems like a more correct way to use the gallery function.

    I suggest you take a look into how the gallery shortcode renders links. The link attribute is passed to wp_get_attachment_link which will filter the output through the wp_get_attachment_link filter. You should be able to override the attachment link there.

    In the wp_get_attachment_link filter, you can test if the image is a generated PDF thumbnail using get_post_meta('PdfThumbnailsPlugin', self::META_KEY, true).

    EDIT: Removed the previous post, not relevant to the question.

    Thanks for your quick replies and the useful hints. Th problem so far was that I wanted to have the PDF thumbnail plugin completely separate from my theme’s PHP code, so I didn’t want to include some PHP code and only used a custom JS plugin to “manipulate” the output code.

    But using your hints, I will create a new (local) version of your plugin where I will handle the issue. Once it’s done, I will send you the ZIP package.

    Plugin Author stianlik


    Nine months since last update, marking this as resolved.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Gallery with thumbnails linking to PDF files’ is closed to new replies.