Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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