Ticket #39330: 39330.patch
File 39330.patch, 1.6 KB (added by , 8 years ago) |
---|
-
class-wp-image-editor-imagick.php
155 155 156 156 // Reading image after Imagick instantiation because `setResolution` 157 157 // 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 } 159 171 172 $document = fopen( $filename, 'r', false, $context ); 173 $this->image->readImageFile( $document ); 174 fclose( $document ); 175 } else { 176 $this->image->readImage( $filename ); 177 } 178 160 179 if ( ! $this->image->valid() ) 161 180 return new WP_Error( 'invalid_image', __('File is not an image.'), $this->file); 162 181 … … 754 773 $this->image->setResolution( 128, 128 ); 755 774 756 775 // 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 } 758 782 } 759 783 catch ( Exception $e ) { 760 784 return new WP_Error( 'pdf_setup_failed', $e->getMessage(), $this->file );