Skip to content

Instantly share code, notes, and snippets.

@code-flow
Last active October 28, 2021 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save code-flow/7a182c05b6bb238082f000653bc85d32 to your computer and use it in GitHub Desktop.
Save code-flow/7a182c05b6bb238082f000653bc85d32 to your computer and use it in GitHub Desktop.
Allows the upload of SVG images into WordPress.
<?php
/**
* Plugin Name: Allow SVG
* Plugin URI: https://wp-typ.de/entwicklung/svg-dateien-in-wordpress-erlauben-so-gehts/
* Description: Allows the upload of SVG images into WordPress.
* Requires at least: 5.0
* Requires PHP: 5.6
* Version: 0.1.1
* Author: Florian Simeth
*/
function wpt2_allowed_mimes( $mimes ) {
if ( ! array_key_exists( 'svg+xml', $mimes ) ) {
$mimes['svg+xml'] = 'image/svg+xml';
}
if ( ! array_key_exists( 'svg', $mimes ) ) {
$mimes['svg'] = 'image/svg';
}
return $mimes;
}
add_filter( 'upload_mimes', 'wpt2_allowed_mimes' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment