How to use SVG in your WordPress media easily

SVG files are not supported by default in your WordPress installation, you can enable SVG support by using one of the following methods:

Method 1: Use a Plugin

  1. Log in to your WordPress admin dashboard.
  2. Go to “Plugins” and click on “Add New.”
  3. Search for a plugin called “Safe SVG” or “SVG Support”.
  4. Install and activate the plugin.
  5. Once activated, the plugin should enable SVG support for your WordPress installation.

Method 2: Edit the Theme’s Functions.php File

  1. Access your WordPress files via FTP or using a file manager provided by your hosting provider.
  2. Locate your active theme’s folder, which is usually located in the “wp-content/themes/” directory.
  3. In the theme’s folder, find the “functions.php” file.
  4. Download a backup copy of the “functions.php” file to your computer as a precaution.
  5. Open the “functions.php” file using a text editor.
  6. Add the following code at the end of the file:
function allow_svg_upload( $mimes ) {
    $mimes['svg'] = 'image/svg+xml';
    return $mimes;
}
add_filter( 'upload_mimes', 'allow_svg_upload' );

 

  1. Save the changes and upload the modified “functions.php” file back to your server, overwriting the existing file if necessary.

By adding this code to your theme’s functions.php file, you are filtering the list of allowed upload file types and including the SVG format as a valid option. This should enable you to upload and use SVG images in your WordPress installation.

After making these changes, you should be able to upload SVG files through the WordPress media uploader and use them on your website. Remember to clear any caching plugins or caching services you may be using to ensure the changes take effect.

Share This Article

Get Started on Creating Your Web Apps with a Reliable Server Today.

If you are searching the best solution for your hosting issue, then check it out.

Leave a Reply

Your email address will not be published. Required fields are marked *