diff --git a/wp-includes/class-wp-image-editor-imagick.php b/wp-includes/class-wp-image-editor-imagick.php index c89706cd58..fc6fc933ae 100644 --- a/wp-includes/class-wp-image-editor-imagick.php +++ b/wp-includes/class-wp-image-editor-imagick.php @@ -149,13 +149,8 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { $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]'; + $filename = $this->pdf_setup(); } // Reading image after Imagick instantiation because `setResolution` @@ -743,4 +738,27 @@ class WP_Image_Editor_Imagick extends WP_Image_Editor { return true; } + /** + * Sets up Imagick for PDF processing. + * Increases rendering DPI and only loads first page. + * + * @since 4.7.0 + * @access protected + * + * @return string|WP_Error File to load or WP_Error on failure. + */ + protected function pdf_setup() { + try { + // By default, PDFs are rendered in a very low resolution. + // We want the thumbnail to be readable, so increase the rendering DPI. + $this->image->setResolution( 128, 128 ); + + // Only load the first page. + return $this->file . '[0]'; + } + catch ( Exception $e ) { + return new WP_Error( 'pdf_setup_failed', $e->getMessage(), $this->file ); + } + } + } diff --git a/wp-includes/version.php b/wp-includes/version.php index 5392cf1ad9..9305feffba 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-beta4-39302'; +$wp_version = '4.7-beta4-39303'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.