wip
This commit is contained in:
@@ -23,8 +23,10 @@ class WP_Image_Editor_GD extends WP_Image_Editor {
|
||||
|
||||
public function __destruct() {
|
||||
if ( $this->image ) {
|
||||
// We don't need the original in memory anymore.
|
||||
imagedestroy( $this->image );
|
||||
if ( PHP_VERSION_ID < 80000 ) { // imagedestroy() has no effect as of PHP 8.0.
|
||||
// We don't need the original in memory anymore.
|
||||
imagedestroy( $this->image );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,8 +190,12 @@ class WP_Image_Editor_GD extends WP_Image_Editor {
|
||||
$resized = $this->_resize( $max_w, $max_h, $crop );
|
||||
|
||||
if ( is_gd_image( $resized ) ) {
|
||||
imagedestroy( $this->image );
|
||||
if ( PHP_VERSION_ID < 80000 ) { // imagedestroy() has no effect as of PHP 8.0.
|
||||
imagedestroy( $this->image );
|
||||
}
|
||||
|
||||
$this->image = $resized;
|
||||
|
||||
return true;
|
||||
|
||||
} elseif ( is_wp_error( $resized ) ) {
|
||||
@@ -324,7 +330,10 @@ class WP_Image_Editor_GD extends WP_Image_Editor {
|
||||
$saved = $resized;
|
||||
} else {
|
||||
$saved = $this->_save( $resized );
|
||||
imagedestroy( $resized );
|
||||
|
||||
if ( PHP_VERSION_ID < 80000 ) { // imagedestroy() has no effect as of PHP 8.0.
|
||||
imagedestroy( $resized );
|
||||
}
|
||||
}
|
||||
|
||||
$this->size = $orig_size;
|
||||
@@ -382,9 +391,13 @@ class WP_Image_Editor_GD extends WP_Image_Editor {
|
||||
imagecopyresampled( $dst, $this->image, 0, 0, (int) $src_x, (int) $src_y, (int) $dst_w, (int) $dst_h, (int) $src_w, (int) $src_h );
|
||||
|
||||
if ( is_gd_image( $dst ) ) {
|
||||
imagedestroy( $this->image );
|
||||
if ( PHP_VERSION_ID < 80000 ) { // imagedestroy() has no effect as of PHP 8.0.
|
||||
imagedestroy( $this->image );
|
||||
}
|
||||
|
||||
$this->image = $dst;
|
||||
$this->update_size();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -408,9 +421,14 @@ class WP_Image_Editor_GD extends WP_Image_Editor {
|
||||
if ( is_gd_image( $rotated ) ) {
|
||||
imagealphablending( $rotated, true );
|
||||
imagesavealpha( $rotated, true );
|
||||
imagedestroy( $this->image );
|
||||
|
||||
if ( PHP_VERSION_ID < 80000 ) { // imagedestroy() has no effect as of PHP 8.0.
|
||||
imagedestroy( $this->image );
|
||||
}
|
||||
|
||||
$this->image = $rotated;
|
||||
$this->update_size();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -439,8 +457,12 @@ class WP_Image_Editor_GD extends WP_Image_Editor {
|
||||
$sh = $horz ? -$h : $h;
|
||||
|
||||
if ( imagecopyresampled( $dst, $this->image, 0, 0, $sx, $sy, $w, $h, $sw, $sh ) ) {
|
||||
imagedestroy( $this->image );
|
||||
if ( PHP_VERSION_ID < 80000 ) { // imagedestroy() has no effect as of PHP 8.0.
|
||||
imagedestroy( $this->image );
|
||||
}
|
||||
|
||||
$this->image = $dst;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user