• Resolved erbrown777

    (@erbrown)


    Good day,

    I cannot upload Webp or Jfif files when adding an event from the frontend. I have no issue adding these files when adding an event in the dashboard.

    My setup is as follows:

    • EM 7.3.6
    • Enable Visual Uploader – Yes
    • File type – Any Type
    • File Types – jfif, webp, gif, jpg, jpeg, png,

    The error I I getting is that only gif, jpg, jpeg, png, are allowed

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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”).

    Thread Starter erbrown777

    (@erbrown)

    Thank you @msykes ! That works!

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.