SVG files not uploading since most recent WP update

I have a snippet in my functions PHP file that allows me to upload SVG files. Since upgrading to the latest version of WP today, I can no longer upload svgs. I also tried a second code snippet from CSS tricks website and that doesn’t work either.

Does anyone know a) what may have caused this with the last update and b) Does anyone know a work around.

Here is the code I normally use:

function svg_mime_types( $mimes ) {
   mimes['svg'] = 'image/svg+xml';
   return $mimes;}
add_filter( 'upload_mimes', 'svg_mime_types' );  

Many thanks



In WordPress 4.7.1 a change was introduced that checks for the real mime type of an uploaded file. This breaks uploading file types like SVG or DOCX. There already exist tickets for this issue in WordPress Core, where you can read more about this:

  • Some Non-image files fail to upload after 4.7.1 (
  • SVG upload support broken in 4.7.1 (

A temporary and recommended workaround (for the time until this issue is fixed) is the following plugin:
Disable Real MIME Check

If you don’t want to use that plugin, here’s the same functionality:

add_filter( 'wp_check_filetype_and_ext', function($data, $file, $filename, $mimes) {
    global $wp_version;

    if ( '4.7.2' !== $wp_version ) {
       return $data;

    $filetype = wp_check_filetype( $filename, $mimes );

    return [
        'ext'             => $filetype['ext'],
        'type'            => $filetype['type'],
        'proper_filename' => $data['proper_filename']

}, 10, 4 );

Notice that this snipped has a version check included to disable the fix as soon as WordPress is updated.


The issue was initially set to be fixed in 4.7.2. But since 4.7.2 was an urgent security release, the fix didn’t make it into that version. It’s now supposed to be fixed in 4.7.3.

Leave a Comment