Make WordPress Core

Ticket #39330: 39330.patch

File 39330.patch, 1.6 KB (added by wordpressrene, 8 years ago)
  • class-wp-image-editor-imagick.php

     
    155155
    156156                        // Reading image after Imagick instantiation because `setResolution`
    157157                        // only applies correctly before the image is read.
    158                         $this->image->readImage( $filename );
     158                        if ( filter_var( $this->file, FILTER_VALIDATE_URL ) !== false ) {
     159                                if ( defined( 'WP_PROXY_HOST' ) && defined( 'WP_PROXY_PORT' ) ) {
     160                                        $context = stream_context_create(
     161                                                array(
     162                                                        'http' => array(
     163                                                                'proxy'           => 'tcp://' . WP_PROXY_HOST . ':' . WP_PROXY_PORT,
     164                                                                'request_fulluri' => true,
     165                                                        )
     166                                                )
     167                                        );
     168                                } else {
     169                                        $context = stream_context_get_default();
     170                                }
    159171
     172                                $document = fopen( $filename, 'r', false, $context );
     173                                $this->image->readImageFile( $document );
     174                                fclose( $document );
     175                        } else {
     176                                $this->image->readImage( $filename );
     177                        }
     178
    160179                        if ( ! $this->image->valid() )
    161180                                return new WP_Error( 'invalid_image', __('File is not an image.'), $this->file);
    162181
     
    754773                        $this->image->setResolution( 128, 128 );
    755774
    756775                        // Only load the first page.
    757                         return $this->file . '[0]';
     776                        // Only load the first page.
     777                        if ( filter_var( $this->file, FILTER_VALIDATE_URL ) !== false ) {
     778                                return $this->file;
     779                        } else {
     780                                return $this->file . '[0]';
     781                        }
    758782                }
    759783                catch ( Exception $e ) {
    760784                        return new WP_Error( 'pdf_setup_failed', $e->getMessage(), $this->file );