• Resolved norbou

    (@norbou)


    Hello David and community,

    I am experiencing an issue with generating thumbnails for older PDF files in my WordPress media library. Here are the key points:

    1. Thumbnails for newly uploaded PDF files are generated correctly. The problem only occurs with thumbnails of older images that have already been generated.
    2. The Media Library Assistant (MLA) plugin reports that the thumbnail has been generated successfully, but it does not display. I have also tried using WP CLI, but all PDF files are skipped.
    3. All thumbnails were previously generated and displayed correctly, but due to a conflict with two other plugins, all thumbnails were deleted and needed to be regenerated.
    4. I have noticed that MLA does generate a new thumbnail for an existing PDF file, but the thumbnail image in the media library links to a different file than the one generated.
    5. For some reason, WordPress seems to think the deleted thumbnails are still present and assigns a numerical suffix (e.g., -1) to the new files, while links to thumbnails in the media library refer to images without suffixes that no longer exist.

    I need advice on how to properly delete all PDF thumbnails from both the file system and the database so that new thumbnails can be generated correctly. I don’t think this is a problem caused by the MLA plugin, which cannot be harmful in any way, but I suspect David will know a magic SQL statement that will solve it in a tenth of a second ??

    Any help would be greatly appreciated.

    Thank you!

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author David Lingren

    (@dglingren)

    Good to hear from you again. Thanks for being a long-time MLA user and for your report.

    I have been unable to reproduce your problem on my system, so I would like more information about what you have on your system.

    When you use MLA to generate thumbnails, I assume you are using the “Thumbnails” bulk action on the Media/Assistant screen, with the Type (o) WP and Existing Items: Delete settings; is that correct? This is working fine on my system.

    You wrote “all thumbnails were deleted and needed to be regenerated.” Does that mean you just deleted the old files, or was there some process that also deleted the reference to them in the WordPress database? How did you delete the old “thumbnails”?

    You wrote “the thumbnail image in the media library links to a different file than the one generated.” Can you tell me where you see the links? Are they in the “Attachment Metadata” text area on the Media/Edit Media page? Are they elements in the “sizes” array? If not, can you tell me what appears in the “Attachment Metadata” text area?

    You wrote “For some reason, WordPress seems to think the deleted thumbnails are still present and assigns a numerical suffix.” That only happens if there is an existing file in the same directory, the directory where the PDF document file is located. Are you sure the JPG files representing the thumbnails are not there?

    Any additional details you can provide will be helpful. Thanks for your understanding.

    Thread Starter norbou

    (@norbou)

    Hi David,
    I wouldn’t wish my problem on anyone to reproduce it, much less you ??

    Yes, I’ve generated several thousand thumbnails just using MLA before and it worked great. It still works now, but it generates thumbnails with a numeric suffix in the title, whereas they don’t show up in the media library at all, as they are linked to the file name without the suffix.

    I didn’t remove the old thumbnails. What happened was that I was removing the language version of the site in the WPML administration with the “Image Regenerate & Select Crop” plugin activated. The latter misinterpreted something and took the initiative to delete the media file thumbnails, probably in an attempt to keep the media library in order. It could have been that he only deleted them on the filesystem, but records of already generated thumbnails (not only PDFs) remained in the database. We can still verify this somehow by running some queries.

    I have filtered some old pdf thumbnails and deleted them using query:
    find . -type f -regex “.-pdf-.(-[0-9]+x[0-9]+)?.jpg” -exec rm -f {} \;
    find . -type f -iname “-[0-9]x[0-9]*.pdf” -exec rm -f {} \;
    find . -type f -iname “-thumb.png” -exec rm -f {} \;

    All these files I have still found in uploads folder.

    Wow, it helps in some cases but the in some cases I still had a problem to see generated thumbnail and it was cased by forcing lowercase in filenames. After switching this function off it works.

    Thank you for your reply and good question, the problem seems to be solved now ??

    If you think, that it is a really good idea, you can use my regular expression for old thumbnails cleanup, but I made the mess also with PDF thumbnail generator plugin, which doesn’t worked well for me.

    Conclusion for others is: use only the MLA plugin and no other ones ??

    • This reply was modified 1 year, 7 months ago by norbou.
    Thread Starter norbou

    (@norbou)

    One edit. It is not necessary to cleanup “-thumb.png” files, which are being generated by Document Gallery plugin.

    Thread Starter norbou

    (@norbou)

    However, in other cases it also doesn’t work, namely when a previously uploaded file contains forbidden characters that are already modified by Worpdpress implicitly since version 5.3. It also does it wrong, it generates correctly modified file names, but the link leads to an unmodified file. I guess there’s no way to arrange it so that WP saves the correctly sanitized names of the generated thumbnails in the database, right?

    Thread Starter norbou

    (@norbou)

    Omg. Another exception is when the pdf file has a thumbnail generated by the Document Gallery plugin in the form of:

    00196-sch6_sw_stonework_elements_schedule_a4-a3.pdf
    00196-sch6_sw_stonework_elements_schedule_a4-a3-thumb.png
    00196-sch6_sw_stonework_elements_schedule_a4-a3-thumb-1.png
    00196-sch6_sw_stonework_elements_schedule_a4-a3-thumb-2.png
    00196-sch6_sw_stonework_elements_schedule_a4-a3-thumb-3.png
    00196-sch6_sw_stonework_elements_schedule_a4-a3-thumb-4.png

    In this case MLA can’t generate anything with any settings at all in that case. That wouldn’t matter, the only problem is that the preview doesn’t show up in the media gallery at all because it’s linked to the image name 00196-sch6_sw_stonework_elements_schedule_a4-a3-pdf.jpg, which simply doesn’t exist.

    Document gallery is simple shortcode to show some PDF files like at the bottom od the this page:
    https://www.arc.cz/portfolio-item/2010-rodinny-dum-v-el-palol/

    I don’t know, why is the thumbnail linked to JPG and not to the PNG which exists and how to repair it in a bulk. MLA just says:
    Item 142403, has native thumbnail.

    Can MLA display a PDF gallery with thumbnails that I could replace with the Document Gallery plugin?

    Plugin Author David Lingren

    (@dglingren)

    Thanks for your updates with all the details on your thumbnail adventures. You have my sympathy!

    I found “Document Gallery By Dan Rossiter” in the WordPress Repository; is that the one?

    I haven’t digested everything you reported, but I wanted to give you a prompt answer to “Can MLA display a PDF gallery with thumbnails that I could replace with the Document Gallery plugin?

    You can display a PDF gallery by simply adding post_mime_type=application/pdf to your other shortcode parameters.

    Let me know if you have problems or further questions about that suggestion.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Regenerating thumbnails for older PDF files not working’ is closed to new replies.