Last active
October 28, 2021 11:05
-
-
Save code-flow/7a182c05b6bb238082f000653bc85d32 to your computer and use it in GitHub Desktop.
Allows the upload of SVG images into WordPress.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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