Skip to content

Instantly share code, notes, and snippets.

@Gkiokan
Created February 6, 2017 14:30
Show Gist options
  • Save Gkiokan/5b9e14bd3aff3add191d9ce1b62cea18 to your computer and use it in GitHub Desktop.
Save Gkiokan/5b9e14bd3aff3add191d9ce1b62cea18 to your computer and use it in GitHub Desktop.
WP 4.7.1+ SVG Broken Upload errors
<?php
/*
SVG fix for 4.7.1+
*/
add_filter( 'wp_check_filetype_and_ext', function($filetype_ext_data, $file, $filename, $mimes) {
if ( substr($filename, -4) === '.svg' ) {
$filetype_ext_data['ext'] = 'svg';
$filetype_ext_data['type'] = 'image/svg+xml';
}
return $filetype_ext_data;
}, 100, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment