Hi!
Thumbs generation is a bit “magic” in Kirby3 and I am trying to explain how I think it works.
Please correct me if my steps below are wrong!
The first part of thumb generation:
- When using
$file->thumb()
, you are calling the thumb method of the file class. This method is defined in the FileModifications trait. - Inside this method the
file::version
component is called (here) - The file::version component checks if an image with the defined specifications already exists, otherwise prepares the job file for lazy thumbnail creation (they are saved in the media/… folder in a .jobs subfolder for each page).
The second part of thumb creation:
- Via routing Kirby realizes that you want to load an image from the media folder that has not yet been generated. You end up in the Media class static thumb method. The job file is used to get the specifications.
- Then the App class thumb method is called
- which calls the thumb component
- which finally uses the Darkroom classes or your own thumbnail creation code.
Long story short: Your pdf thumb generation fails in the second step of part 1. file::version
checks if a file is resizable and a pdf is not.
You’ll need to adjust the file::version
component aswell or use another solution, e.g. an after upload hook.