SVG (Scalable Vector Graphics) icons enhance your eCommerce store’s visual appeal while maintaining crisp quality at any size. DigiCommerce supports two methods for uploading SVG icons: using the SVG Support plugin or implementing custom code in your theme’s functions.php file.
Using the SVG Support Plugin
The SVG Support plugin offers a straightforward way to enable SVG uploads in your WordPress media library. After installing and activating the plugin, follow these steps:
- Navigate to Settings → SVG Support in your WordPress dashboard
- Enable “Restrict to Administrators” to ensure only admin users can upload SVG files
- Check “Enable Advanced Mode” to use SVG files anywhere in your DigiCommerce store
- Save your changes
You can now upload SVG icons through the WordPress media library and use them throughout your DigiCommerce products, and interface elements.
Enabling SVG Upload via functions.php
If you prefer not to use a plugin, you can add custom code to your theme’s functions.php file. This method gives you more control over the SVG upload process.
Add the following code to your theme’s functions.php file:
function digicommerce_enable_svg_upload( $mimes ) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter( 'upload_mimes', 'digicommerce_enable_svg_upload' );
This code adds SVG support uploads.
Best Practices for SVG Usage
- Use compressed SVG files to optimize loading times
- Ensure SVG files are properly formatted and contain only necessary code
- Set appropriate width and height attributes for consistent display
- Test SVG icons across different browsers for compatibility
Remember to optimize your SVG files before uploading them to maintain fast loading times and smooth performance in your DigiCommerce store.