enable svg uploads

This commit is contained in:
Aadil Ayub 2024-04-29 11:07:25 +05:00
parent 3481e1dd40
commit 19037858b9

View File

@ -63,4 +63,41 @@ add_action('init', function () {
}
});
/*== END DISABLE COMMENTS ==*/
/*== END DISABLE COMMENTS ==*/
/*== ENABLE SVG UPLOADS ==*/
// Allow SVG
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' );
function fix_svg() {
echo '<style type="text/css">
.attachment-266x266, .thumbnail img {
width: 100% !important;
height: auto !important;
}
</style>';
}
add_action( 'admin_head', 'fix_svg' );
/*== END ENABLE SVG UPLOADS ==*/