From 0458c96beae025f5854cc3756b49337d4499e16c Mon Sep 17 00:00:00 2001 From: Aadil Ayub Date: Thu, 30 May 2024 17:44:22 +0500 Subject: [PATCH] enable svg uploads --- functions.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/functions.php b/functions.php index e880ab0..835d1db 100644 --- a/functions.php +++ b/functions.php @@ -31,6 +31,30 @@ function custom_wp_theme_json_default( $theme_json ) { } add_filter( 'wp_theme_json_data_default', 'custom_wp_theme_json_default' ); +// enable svg uploads +add_filter( 'wp_check_filetype_and_ext', function($data, $file, $filename, $mimes) { + + global $wp_version; + if ( $wp_version !== '4.7.1' ) { + return $data; + } + + $filetype = wp_check_filetype( $filename, $mimes ); + + return [ + 'ext' => $filetype['ext'], + 'type' => $filetype['type'], + 'proper_filename' => $data['proper_filename'] + ]; + +}, 10, 4 ); +function cc_mime_types($mimes) { + $mimes['svg'] = 'image/svg+xml'; + return $mimes; +} +add_filter('upload_mimes', 'cc_mime_types'); + +// define block styles function jett_block_styles() { register_block_style( 'core/heading',