All Good Things Must Come To An End

As you all know, I have been doing WordPress plugins and supporting it for the past 6 years. These 6 years of my life, I have been through my polytechnic education, my national service as well as my university education.

I just graduated from university in December 2009 and have been looking for full-time jobs. I am offered a full-time job and will be starting work on 1st February 2010.

I regret to say that I am NOT ABLE to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

However, I WILL still update my plugins whenever I can and you still can report bugs to me via email and I will try to fix it.


Author Topic: Tutorial: Simple way to add image thumbnails to PDF file downloads  (Read 1694 times)

0 Members and 1 Guest are viewing this topic.

Offline eyetrap

  • Newbie
  • *
  • Posts: 1
    • View Profile
Ok--Automatic PDF thumbnail creation simply using PHP is essentially an impossible task--I've done a lot of research and can't find anyone who's done it before.  So the only way to produce great thumbnails is to produce them using a batch in Photoshop. 
Start recording an action in Photoshop, the open a PDF and resize to your thumbnail width then set the canvas size to your set height (this standardizes your PFD thumbnails sizes, whether your pdfs are in landscape or portrait format).  Once you have an action, you can preform a automation batch on a whole folder of PDFs on your local computer to produce thumbnails.

The trick to making your thumbnails work with WP-DownloadManager is to name them in this format:
Document Name + .pdf + .jpg  (this is how you have to form the filename if you're using the batch in photoshop)
You can manually name your photos like this:  my_pdf_docuement.pdf.jpg

Then upload your thumbnails to a specific directory, and then use that directory in the WP-DownloadManager template.

Code: [Select]
<p>
<img src="http://www.YOURSITE.com/wp/wp-content/images/pdfs/%FILE_NAME%.jpg" alt="" title="" style="vertical-align: middle;" />
<strong>
<a href="%FILE_DOWNLOAD_URL%">%FILE_NAME%</a>
</strong>
(%FILE_SIZE%)
<br />
%FILE_DESCRIPTION%
</p>
YEILDS THIS RESULT IN THE BROWSER:
Code: [Select]
<p>
<img style="vertical-align: middle;" title="" alt="" src=" http://www.YOURSITE.com/wp/wp-content/images/pdfs/my_pdf_document.pdf.jpg"/>
<strong>
<a href="http://www.YOURSITE.com/wp/download/1/">my_pdf_document.pdf</a>
</strong>
(170.6 KiB)
<br/>
This is the description of this file
</p>

So you're essentially just using the %FILE_NAME% to form the link to the jpg files.  The trick is to make sure your jpg and pdf filenames match up.

I've been scratching my head for a good solution for PDF thumbnails in wordpress for weeks and this seems to be the easiest solution I've found.  But this is assuming you're only going to be offering PDFs for downloads.  If you are offering ZIP or DOC downloads, you will need to manually create a thumbnail image with the correct filename.

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,536
    • View Profile
  • WordPress Version: WordPress 2.9.x
  • Theme Name: lesterchan.net v3.4
Thanks for sharing =D

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline Karlsmith

  • Newbie
  • *
  • Posts: 1
    • View Profile
  • WordPress Version: WordPress 2.8.x
  • Theme Name: Karlsmith
Nice .. thank you for posting  :)
« Last Edit: 05 February 2010, 02:43 by Karlsmith »