WordPress 4.7 makes it easier to preview PDFs in the media library by generating image representations of the first page, which are now used throughout the media library and media attachment screens.
WP_Image_Editor is available that supports PDF, the following sizes are generated:
- Full size representation, rendered at 128dpi.
- Thumbnail (without cropping)
The sizes generated can be modified, or the feature disabled entirely via the new
fallback_intermediate_image_sizes filter Filters are one of the two types of Hooks https://codex.wordpress.org/Plugin_API/Hooks. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output., and are all stored in the
sizes array in attachment meta Meta is a term that refers to the inside workings of a group. For us, this is the team that works on internal WordPress sites like WordCamp Central and Make WordPress..
The preview images generated are used within the Media screen, Gallery, Attachment Details, and on the Attachment page for PDFs.
Core Core is the set of software required to run WordPress. The Core Development Team builds WordPress. support is provided through
WP_Image_Editor_Imagick and requires Imagick, ImageMagick, and Ghostscript support. When not supported, or if the generation fails, WordPress falls back to previous behavior and saves the attachment without adding image previews to meta.
For more context, see #31050 for the primary ticket Created for both bug reports and feature development on the bug tracker. and #38594 for the filter.
Since this change requires having Imagick load only the first page of a PDF for performance reasons, this means that if you rely on core loading the entire PDF for your extension of
WP_Image_Editor_Imagick, this will no longer function as expected (See: #38832).
As a result, in , the PDF setup code was moved to
WP_Image_Editor_Imagick->pdf_setup(), which can be overridden to restore the previous behavior if needed.
#4-7, #dev-notes, #media
You must be logged in to post a comment.