I’m trying to figure out why one of my WordPress sites is not generating thumbnails for PDF uploads. It works on my dev and staging sites. When comparing them, the only difference that I can find is that my production site is running PHP 7.2, whereas dev and staging are running PHP 7.3. I have the imagick extension installed on all of them.
Thumbnails are being generated for image files – it’s only PDF files that aren’t working. The iMagick PHP extension should be all that’s needed, right? I’ve turned on WordPress debug logging and looked for errors there and in the Apache error logs, but have found nothing.
Any suggestions?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
I found a solution! I hope this helps save some time and frustration for others that might encounter this problem. It turns out that it isn’t WordPress or PHP.
After a lot of digging, I came across this discussion by some members of the WordPress Core team: https://core.trac.wordpress.org/ticket/48853. It says that there is some kind of issue in Ghostscript 8.70 and below that prevents the thumbnails from being generated for PDFs. So, I checked the installed version of Ghostscript. Sure enough, it’s 8.70. I looked for a yum update, but 8.70 is the latest available for the server OS (CentOS 6).
I saw several posts that described installing a newer version from a tar.gz file, so I tried that using the defaults. WordPress still would not generate PDF thumbnails. Rats. Even though the command line reported the newer version of Ghostscript, it was like WordPress didn’t see it. Then I saw a post somewhere that seemed to indicate that WordPress was looking in /usr/bin for the Ghostscript executable. The default ./configure command (with no arguments) installed GS in /usr/local/bin. After installing GS into /usr/bin instead, WordPress was finally able to generate PDF thumbnails!
Here are the steps for CentOS 6:
wget https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs919/ghostscript-9.19.tar.gz(I saw somewhere that if you go higher than that version with CentOS 6, you’ll have to mess with updating compilers and linkers and whatnot.)tar -zxvf ghostscript-9.19.tar.gzcd ghostscript-9.19./configure --prefix=/usr(To install where WordPress expects to find GS)makesudo make install
That’s it! I also bounced Apache for good measure, but I’m not sure that’s necessary. Hope this helps!
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0