Skip to content

Commit 7f757c7

Browse files
committed
Separate image creation failure and truecolor checks for clarity
1 parent 731d3b0 commit 7f757c7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

plugins/webp-uploads/hooks.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,15 @@ function webp_uploads_convert_palette_png_to_truecolor( $file ): array {
850850
}
851851

852852
$image = imagecreatefrompng( $file['tmp_name'] );
853-
if ( false === $image || imageistruecolor( $image ) ) {
853+
854+
// Check if the image was created successfully.
855+
if ( false === $image ) {
856+
return $file;
857+
}
858+
859+
// Check if the image is already truecolor.
860+
if ( imageistruecolor( $image ) ) {
861+
imagedestroy( $image );
854862
return $file;
855863
}
856864

0 commit comments

Comments
 (0)