mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-03 06:57:35 +01:00
Fix editing images with GD when using streams.
Props rmccue, markoheijnen, nacin fixes #24459 git-svn-id: http://core.svn.wordpress.org/trunk@24727 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8d9a830c3c
commit
46ae92b9e4
@ -401,4 +401,22 @@ class WP_Image_Editor_GD extends WP_Image_Editor {
|
|||||||
return imagejpeg( $this->image, null, $this->quality );
|
return imagejpeg( $this->image, null, $this->quality );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Either calls editor's save function or handles file as a stream.
|
||||||
|
*
|
||||||
|
* @since 3.5.0
|
||||||
|
* @access protected
|
||||||
|
*
|
||||||
|
* @param string|stream $filename
|
||||||
|
* @param callable $function
|
||||||
|
* @param array $arguments
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
protected function make_image( $filename, $function, $arguments ) {
|
||||||
|
if ( wp_is_stream( $filename ) )
|
||||||
|
$arguments[1] = null;
|
||||||
|
|
||||||
|
return parent::make_image( $filename, $function, $arguments );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -327,14 +327,11 @@ abstract class WP_Image_Editor {
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
protected function make_image( $filename, $function, $arguments ) {
|
protected function make_image( $filename, $function, $arguments ) {
|
||||||
$dst_file = $filename;
|
|
||||||
|
|
||||||
// The directory containing the original file may no longer exist when using a replication plugin.
|
|
||||||
wp_mkdir_p( dirname( $dst_file ) );
|
|
||||||
|
|
||||||
if ( $stream = wp_is_stream( $filename ) ) {
|
if ( $stream = wp_is_stream( $filename ) ) {
|
||||||
$filename = null;
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
} else {
|
||||||
|
// The directory containing the original file may no longer exist when using a replication plugin.
|
||||||
|
wp_mkdir_p( dirname( $filename ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = call_user_func_array( $function, $arguments );
|
$result = call_user_func_array( $function, $arguments );
|
||||||
@ -342,7 +339,7 @@ abstract class WP_Image_Editor {
|
|||||||
if ( $result && $stream ) {
|
if ( $result && $stream ) {
|
||||||
$contents = ob_get_contents();
|
$contents = ob_get_contents();
|
||||||
|
|
||||||
$fp = fopen( $dst_file, 'w' );
|
$fp = fopen( $filename, 'w' );
|
||||||
|
|
||||||
if ( ! $fp )
|
if ( ! $fp )
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user