WordPress.org

Make WordPress Core

Changeset 39187


Ignore:
Timestamp:
11/09/2016 09:04:04 PM (3 years ago)
Author:
mikeschroder
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-image-editor-imagick.php

    r38949 r39187  
    148148            $this->image = new Imagick();
    149149            $file_parts = pathinfo( $this->file );
     150            $filename = $this->file;
    150151
    151152            // By default, PDFs are rendered in a very low resolution.
     
    153154            if ( 'pdf' == strtolower( $file_parts['extension'] ) ) {
    154155                $this->image->setResolution( 128, 128 );
     156
     157                // Only load the first page.
     158                $filename .= '[0]';
    155159            }
    156160
    157161            // Reading image after Imagick instantiation because `setResolution`
    158162            // only applies correctly before the image is read.
    159             $this->image->readImage( $this->file );
     163            $this->image->readImage( $filename );
    160164
    161165            if ( ! $this->image->valid() )
Note: See TracChangeset for help on using the changeset viewer.