Permite o upload de tipos de arquivo adicionais (SVG, WebP, etc.) no WordPress.
add_filter('upload_mimes', function (array $mimes): array {
$mimes['svg'] = 'image/svg+xml';
$mimes['webp'] = 'image/webp';
$mimes['avif'] = 'image/avif';
return $mimes;
});
// Verificar tipo real do arquivo para SVG
add_filter('wp_check_filetype_and_ext', function ($data, $file, $filename) {
if (substr($filename, -4) === '.svg') {
$data['ext'] = 'svg';
$data['type'] = 'image/svg+xml';
}
return $data;
}, 10, 3);