Closed MathieuLamiot closed 7 months ago
I don't know which file type would not match any mime type. But if we find one, we can apply the optimization process to it to trigger the issue.
Replace the code in /classes/Optimization/Process/AbstractProcess.php:595 by:
if ( '' === $extension ) {
$response = new WP_Error(
'no_extension',
__( 'With no extension, this file cannot be optimized.', 'imagify' )
);
} else if ( ! $extension ) {
$response = new WP_Error(
'extension_not_mime',
__( 'This file has an extension that does not match a mime type.', 'imagify' )
);
} else {
$response = new WP_Error(
'extension_not_supported',
sprintf(
/* translators: %s is a file extension. */
__( '%s cannot be optimized.', 'imagify' ),
'<code>' . esc_html( strtolower( $extension ) ) . '</code>'
)
);
}
This adds an exception if the file type does not match mime type.
Context Issue reported on Slack: https://wp-media.slack.com/archives/C056ZJMHG0P/p1712218266722999
Expected behavior
Additional Information
Stack trace:
The issue seem to come from the fact that wp_check_filetype can return false.
The suggested fix in the thread seem to work.