Plugin Author
Marcus
(@msykes)
Latest update will add webp, but for jfif you need a snippet like so:
<?php
/**
* Allow .jfif image uploads (it's just JPEG with a different extension).
* Layer 1+2 satisfy WordPress core; layer 3 satisfies the Events Manager frontend uploader.
*/
// 1. Tell WordPress core .jfif is an allowed type, mapped to JPEG.
add_filter( 'upload_mimes', function ( $mimes ) {
$mimes['jfif'] = 'image/jpeg';
return $mimes;
} );
// 2. WP's real-mime check returns image/jpeg for a .jfif file but doesn't know the
// extension; nudge it through so media_handle_upload() / wp_handle_upload() accept it.
add_filter( 'wp_check_filetype_and_ext', function ( $data, $file, $filename, $mimes ) {
if ( empty( $data['ext'] ) && empty( $data['type'] ) ) {
$check = wp_check_filetype( $filename, $mimes );
if ( 'jfif' === strtolower( (string) $check['ext'] ) ) {
$data['ext'] = 'jfif';
$data['type'] = 'image/jpeg';
}
}
return $data;
}, 10, 4 );
// 3. Register jfif in Events Manager's frontend uploader registry (JPEG content).
add_action( 'em_uploads_uploader_init', function () {
\EM\Uploads\Uploader::$supported_file_types['jfif'] = array(
'exif_type' => 2, // IMAGETYPE_JPEG — .jfif is JPEG data
'mime' => array( 'image/jpeg' ),
'type' => 'image',
);
} );
In both cases, in Events Manager > Settings > the uploads/file-types setting, make sure jfif/ webp is in the allowed extensions list (or leave it on “Any Type”).
Thank you @msykes ! That works!