Allow SVG file uploads using the WordPress Media Library uploader plus direct styling of SVG elements using CSS.
When using SVG images on your WordPress site, it can be hard to style elements within the SVG using CSS. Now you can, easily!
Scalable Vector Graphics (SVG) are becoming common place in modern web design, allowing you to embed images with small file sizes that are scalable to any visual size without loss of quality.
This plugin not only provides SVG Support like the name says, it also allows you to easily embed your full SVG file's code using a simple IMG tag.
By adding the class
"style-svg" to your IMG elements, this plugin dynamically replaces any IMG elements containing the
"style-svg" class with your complete SVG.
The main purpose of this is to allow styling of SVG elements. Usually your styling options are restricted when using
img tags alone.
Firstly, install SVG Support (this plugin) and activate it.
Once activated, you can simply upload SVG images to your media library like any other file.
As an administrator, you can go to the admin settings page 'Settings' > 'SVG Support' and restrict SVG file uploads to administrators only and even define a custom CSS class to target if you wish.
Now, embed your SVG images just like you would a standard image with the addition of adding (in text view) the class
"style-svg" (or the custom class you defined) to your IMG tags that you want this plugin to swap out with your actual SVG code. You can also remove any other attributes from the tag and use CSS to manage the size.
<img class="style-svg" alt="alt-text" src="image-source.svg" />
<img class="your-custom-class" alt="alt-text" src="image-source.svg" />
The whole IMG tag element will now be dynamically replaced by the actual code of your SVG, making the inner content targetable.
This allows you to target elements within your SVG using CSS.
Please Note: You will need to set your own height and width in your CSS for SVG files to display correctly.
If you are having any issues, please use the support tab and I will try my best to get back to you quickly
As with allowing uploads of any files, there is potential risks involved. Only allow users to upload SVG files if you trust them. You have the option to restrict SVG usage to Administrators only from the settings page. By default, anyone with Media Library access or upload_files capability will be able to upload SVG files (that is Administrators, Authors and Editors).
Note: This plugin is localized/translateable by default. This is very important for all users worldwide. So please contribute your language to the plugin to make it even more useful.
For translating I recommend "Loco Translate" plugin and for validating the "Poedit Editor".
Note: This is the second plugin I have submitted to the WordPress repository, I hope you like it. Please take a moment to rate it and click 'works' under compatibility with your version of WordPress.
As always, feel free to send me any suggestions.
Requires: 4.0 or higher
Compatible up to: 4.6.1
Last Updated: 5 months ago
Active Installs: 30,000+
2 of 8 support threads in the last two months have been marked resolved.
Got something to say? Need help?