# Enabling SVG file support in WordPress

> Allow SVG uploads in WordPress safely using a plugin or custom code, so you can use scalable logos and icons.

Source: https://helpcenter.ruachost.com/wordpress/guides/enabling-svg-file-support-in-wordpress/

By default, WordPress does not allow uploading **SVG (Scalable Vector Graphics)** files due to potential security risks. However, SVGs are lightweight, scalable, and perfect for logos, icons, and illustrations. On **ruachost.com**, you can safely enable SVG support using plugins or custom code.

## Why Use SVGs?

- Crisp and scalable graphics at any resolution.
- Smaller file sizes compared to PNG/JPEG.
- Ideal for responsive design and retina displays.
- Easy to style with CSS.

## Method 1: Use a Plugin (Recommended)

1. **Log in to WordPress** with an administrator account.
2. In the dashboard, go to **Plugins → Add New**.
3. Search for **SVG Support**.
4. Click **Install Now**, then **Activate**.
5. Go to **Settings → SVG Support**.
6. Enable **Restrict to Administrators** (recommended for security).
7. Upload SVG files via the Media Library.

✅ SVGs are now supported and can be used in posts, pages, and themes.

## Method 2: Add Custom Code

If you prefer not to use a plugin:

1. In the dashboard, go to **Appearance → Theme Editor**.
2. Open the **functions.php** file of your active theme.
3. Add the following code snippet:

   ```
   // Enable SVG file uploads
   function enable_svg_uploads($mimes) {
       $mimes['svg'] = 'image/svg+xml';
       return $mimes;
   }
   add_filter('upload_mimes', 'enable_svg_uploads');
   ```
4. Save changes.
5. You can now upload SVG files via the Media Library.

⚠️ Note: This method does not sanitize SVGs. Only upload trusted files.

##

## Security Considerations

- SVGs can contain malicious code if not sanitized.
- Always use trusted sources for SVG files.
- Consider using a plugin that sanitizes SVGs automatically.
- Restrict SVG uploads to administrators for safety.
