• Services
    • Web Hosting
    • Reseller Hosting
    • VPS Hosting
    • Dedicated Hosting
  • Domains
  • Features
  • Company
    • About Us
    • Server Locations
    • Affiliates
    • Company Blog
  • Support
  • Client Login
  • Services
    • Web Hosting
    • Reseller Hosting
    • VPS Hosting
    • Dedicated Hosting
  • Domains
  • Features
  • Company
    • About Us
    • Server Locations
    • Affiliates
    • Company Blog
  • Support
  • Client Login
Home/Article/Scripts & Apps/WordPress/How to Enable SVG File Support in WordPress

How to Enable SVG File Support in WordPress

Written by VernalWeb
June 15, 2023

SVG (Scalable Vector Graphics) files are a popular format for web designers and developers as they provide high-quality, scalable graphics that adapt well to different screen sizes. However, by default, WordPress restricts the upload of SVG files due to security concerns. If you need to enable SVG file support in your WordPress website, there are several methods you can follow. In this article, we will explore two methods of enabling SVG file support in WordPress.

Method 1: Using a Plugin

One of the easiest ways to enable SVG file support in WordPress is by using a dedicated plugin. The “Safe SVG” plugin is a popular choice as it not only allows you to upload SVG files but also ensures that the code within the SVG files is secure. Here’s how to use this plugin:

  1. Log in to your WordPress admin dashboard.
  2. Navigate to “Plugins” in the left-hand menu and click on “Add New.”
  3. In the search bar, type Safe SVG and press Enter.
  4. Locate the Safe SVG plugin and click on the “Install Now” button.
  5. After installation, click on the “Activate” button to activate the plugin.
  6. Once activated, you can go to “Settings” > Safe SVG to configure the plugin’s settings.
  7. In the plugin settings, you can choose to enable SVG support for specific user roles, configure allowed SVG MIME types, and set security options for the uploaded SVG files.
  8. Save the settings, and now you should be able to upload SVG files using the WordPress media uploader.

Method 2: Editing WordPress Functions.php File

If you prefer a manual approach without relying on plugins, you can enable SVG file support by adding code to the functions.php file of your WordPress theme. Here’s how:

  1. Login to cPanel and go to File Manager.
  2. Navigate to public_html -> wp-includes. Scroll down until you locate functions.php.
  3. Find the functions.php file within your theme’s directory and download a backup copy for safety.
  4. Open the functions.php file in a text editor.
  5. Add the following code at the end of the file:
function add_file_types_to_uploads($file_types){
$new_filetypes = array();
$new_filetypes['svg'] = 'image/svg+xml';
$file_types = array_merge($file_types, $new_filetypes );
return $file_types;
}
add_filter('upload_mimes', 'add_file_types_to_uploads');
  1. Save the changes and upload the modified functions.php file back to your WordPress theme directory.

Conclusion

Enabling SVG file support in WordPress allows you to take advantage of this versatile vector graphics format for your website. Whether you choose to use a plugin or edit the functions.php file, following any of these methods will enable you to upload SVG files and enhance your design capabilities within the WordPress platform. Remember to exercise caution when working with SVG files and ensure they come from trusted sources to maintain the security of your website.

Tags:SVGWordPress SVG FileSVG File Support

Was this helpful?

Yes  No
Related Articles
  • How to Backup WordPress Website to DropBox
  • How to Configure WordPress to Use SMTP For Sending Emails
  • How to Fix the Error Establishing a Database Connection in WordPress
  • How To Fix A Syntax Error in WordPress
  • How To Fix 500 Internal Server Error in WordPress
  • How to Fix “LiteSpeed Cache is disabled” Error in WordPress

Didn't find your answer? Submit Ticket

Latest Articles

  • How to show Hidden Files (.htaccess) in cPanel File Manager
  • Setup a Domain Redirection in cPanel
  • Create a MySQL Database and a User from cPanel
  • Remove page extensions using .htaccess
  • Cron Job Usage & Policy
  • © 2014 - 2025 VernalWeb. All rights reserved.