Wordpress Design Articles

Add SVG image in WordPress Web Design

There are some security issues when you try to upload SVG file in WordPress through media. It gives you some security error while uploading it directly from media. By using PHP language you can have the most flexible and easiest solution to add simple function in your WordPress theme in functions.php file and by calling it through filter we can successfully upload our SVG files through Media and it is really useful for a website development company.

By adding the following function you can easily upload SVG images in WordPress. Open your functions.php file and add this code at the bottom of the page. It will also allow user to add other MIME types too.

custom_mtypes( $m ){
    $m[‘svg’] = ‘image/svg+xml’;
    $m[‘svgz’] = ‘image/svg+xml’;
    return $m;
add_filter( ‘upload_mimes’, ‘custom_mtypes’ );

The above function allows both .SVG and .SVGZ mime type support to your WordPress theme design and development through which you can simply call your .SVG image from media gallery and upload it in any page you want.

Why SVG is a Security Risk?

WordPress is a highly secure platform and SVG is a security risk because its wrapped in XML so basically XML is the problem through which hackers can easily interact with your data, crash your server and get access on all of your server data and passwords and can also access on your server through DOS these such hackers are called XML External Entity hackers.