How to create thumbnail of different files?

You’re already looking in the right places. (And nowadays WordPress already supports PDF thumbnails through ImageMagickcode.)

To add a new thumbnail generator, you’ll need to:

  • write a new WP_Image_Editor class that supports the file type or types you want – you’ll want to extend the base class and override at least
    • test()
    • load()
    • supports_mime_type() – to match the content types of the files you want to preview
    • multi_resize() – this is the method called to generate thumbnails
  • hook the wp_image_editors filter, and in the hook implementation include your editor class (if you haven’t already) and add the class name to the filtered list, with whatever priority you want.