最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugin development - How to create thumbnail of different files?

programmeradmin0浏览0评论

I am storing my uploads in a separate folder and using separate table to save the location in database.

I have gone through WP_Image_Editor , wp_image_editor_gd and wp_image_editor_imagick .

I also tried wp_insert_attachment and wp_generate_attachment_metadata

Is there any way to create thumbnails for PDF, video, doc, RAR, and ZIP using these classes or any other classes / functions in wordpress ?

Please let me know, if I should provide more detail on it or any question you want me to answer to help me.

I am storing my uploads in a separate folder and using separate table to save the location in database.

I have gone through WP_Image_Editor , wp_image_editor_gd and wp_image_editor_imagick .

I also tried wp_insert_attachment and wp_generate_attachment_metadata

Is there any way to create thumbnails for PDF, video, doc, RAR, and ZIP using these classes or any other classes / functions in wordpress ?

Please let me know, if I should provide more detail on it or any question you want me to answer to help me.

Share Improve this question edited Jul 12, 2019 at 9:01 Glorfindel 6093 gold badges10 silver badges18 bronze badges asked Jun 27, 2016 at 11:58 Prafulla Kumar SahuPrafulla Kumar Sahu 2631 gold badge4 silver badges19 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You're already looking in the right places. (And nowadays WordPress already supports PDF thumbnails through ImageMagick - code.)

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.
发布评论

评论列表(0)

  1. 暂无评论