Media: Only load first PDF page for thumbnails.
To improve performance, directly load the first page of uploaded PDFs to reduce the total clock time necessary to generate thumbnails. Props dglingren, lukecavanagh, helen, johnbillion, mikeschroder. See #38522. Built from https://develop.svn.wordpress.org/trunk@39187 git-svn-id: http://core.svn.wordpress.org/trunk@39127 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3b008dc2a0
commit
5cdb46c16a
|
@ -147,16 +147,20 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor {
|
|||
try {
|
||||
$this->image = new Imagick();
|
||||
$file_parts = pathinfo( $this->file );
|
||||
$filename = $this->file;
|
||||
|
||||
// By default, PDFs are rendered in a very low resolution.
|
||||
// We want the thumbnail to be readable, so increase the rendering dpi.
|
||||
if ( 'pdf' == strtolower( $file_parts['extension'] ) ) {
|
||||
$this->image->setResolution( 128, 128 );
|
||||
|
||||
// Only load the first page.
|
||||
$filename .= '[0]';
|
||||
}
|
||||
|
||||
// Reading image after Imagick instantiation because `setResolution`
|
||||
// only applies correctly before the image is read.
|
||||
$this->image->readImage( $this->file );
|
||||
$this->image->readImage( $filename );
|
||||
|
||||
if ( ! $this->image->valid() )
|
||||
return new WP_Error( 'invalid_image', __('File is not an image.'), $this->file);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.7-beta2-39186';
|
||||
$wp_version = '4.7-beta2-39187';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue