Skip to content

Commit 7443e68

Browse files
committed
Improve PNG type checking
1 parent ef9a9f9 commit 7443e68

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

plugins/webp-uploads/hooks.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -822,8 +822,11 @@ function webp_uploads_convert_palette_png_to_truecolor( $file ): array {
822822
if ( ! isset( $file['tmp_name'], $file['name'] ) ) {
823823
return $file;
824824
}
825-
826-
if ( 'png' !== strtolower( pathinfo( $file['name'], PATHINFO_EXTENSION ) ) ) {
825+
if ( isset( $file['type'] ) && is_string( $file['type'] ) ) {
826+
if ( 'image/png' !== strtolower( $file['type'] ) ) {
827+
return $file;
828+
}
829+
} elseif ( 'image/png' !== wp_check_filetype( $file['name'] )['type'] ) {
827830
return $file;
828831
}
829832

0 commit comments

Comments
 (0)