* Allow to upload SVG in the media library.
 * @param array $mimes List of approved MIME types.
 * @return array
function dorzki_allow_svg_upload( $mimes ) {

  $mimes['svg'] = 'image/svg+xml';
  return $mimes;

add_filter( 'upload_mimes', 'dorzki_allow_svg_upload' );

How to use it?

Usually adding functionality to a WordPress site is by creating a plugin.
However you can simply copy the code and paste it in your child theme’s functions.php file at the end of the file, just before ?>.

For JavaScript code you will need to add them to your theme’s main JavaScript file.

Having issues with the code?

If the code doesn’t work or you get an error please let us know in the comments section.
We will do our best to fix it as-soon-as-possible and update the code on this page.


Leave a Reply