Retina displays have become the latest talk of the town. With more and more attention being paid to the concept of using retina displays, a majority of entrepreneurs have switched to usage of SVGs(Scalable Vector Graphics) in their corporate websites. We all know that mere failure to adjust the website images in accordance to the high resolution screens is something that can’t be avoided. It is quite essential to ensure that the SVGs are being utilized in a way that the images can be easily scaled up in a proper manner. So, if you’re running a WordPress powered website or are about to build one, do opt for adding SVGs which will make your website compatible with all retina-like screens. This is a post which highlights the significance of SVGs and their correct use in WordPress powered websites.
Exploring SVGs and their importance
Ever since its inception in the year 1999, SVG has been used by a majority of industry biggies like Apple, IBM and Adobe. It is basically a file extension for a vector graphics image file format that’s been created by W3C for describing images using mathematical equations. Available in some popular variants like SVG 1.0, SVG 1.1 and SVG Tiny(SVGT) and SVG Basic(SVGB), SVG uses XML(Extensible Markup Language) and has proved as a good option for improving display properties of every kind of website. Talking about the significance of SVG, it allows you to prevent your images from appearing as blurred on screens with different resolutions. The best thing about SVG files is that they are smaller and much more convenient to compress as compared to other file formats. Do note that graphics with SVG will be printed in higher resolutions. Also, you can gain access to a variety of tools like Notepad for editing SVG files. Images with SVG file formats are both, scalable and zoomable. And not to forget, like a variety of other graphics, SVG files also work as static or animated images.
Getting to know about some prominent advantages of SVGs
SVGs are fully scalable
With smartphones and tablets replacing the traditional desktops, SVGs serve as a great asset for responsive designs which need to target a wide collection of hand-held devices. Since SVGs are scalable, it becomes convenient for you to scale your logo or chart so as to adapt to different screens with high resolutions.
SVG doesn’t include fixed set of dots
Since SVG is defined by XML format and doesn’t comprise of fixed set of dots, it can be effectively saved as the smallest size, whatever is possible. That means, no matter how bigger your graphic gets, the XML that describes it will only be transmitted to the client.
Making changes to an SVG is quite convenient
Unlike other file formats, in case of an SVG, if you tend to make a mistake, you can easily make the required changes by altering the coordinates or words within the default/custom text editor.
Ideal for websites offering a lot of information
SVGs make it easy to create detailed graphics that can showcase multiple details impressively. And that’s not all. With SVG, you can make your illustrations look sharper as compared to other high resolution images. Vector graphics look great in print and are a lot easier to understand too.
SVGs are fuly accessible and search engine friendly
SVGs are completely accessible i.e. every text will remain text and something or the other appears even when the browser doesn’t support the website elements. Additionally, SVG code can be easily read and understood by both, humans and machines. Search engine giant Google, parses SVG’s instantly.
DOM handling is a complete breeze in SVG
SVGs come with a DOM making it convenient to attach event handlers in addition to altering elements as done for other HTML blocks. That means, in order to move a particular item, all you need to do is simply change the related co-ordinates.
The use of SVGs in WordPress website
By default, WordPress treats SVGs as a security threat and hence doesn’t allow you to add them to your media uploader. But, there is nothing to fear of. If you’re inclined on using SVGs in your WordPress powered website, then you can simply give ‘Media Library Uploader’ the permission to upload the files with SVG format. For this, all you need to do is simply open the theme’s functions.php (available within wp-includes folder) and add the below mentioned code snippet to it:
function wp_svg_fnc($arr = array() )
{
$arr[‘svg’] = ‘image/svg+xml';
return $arr;
}
add_filters( ‘mime_types’, ‘wp_svg_fnc’);
After having uploaded the SVGs to your WordPress website’s Media Library Uploader, you may face an issue wherein the SVG might either look very small or too large.
Let’s have a closer look at what happens after adding SVG in WordPress editor online
After you’re done with adding SVG in WordPress editor online, the default height or width attributes of all your images will be automatically set to 1px × 1px. This means that your images would practically become invisible.
Unlike the above scenario, using SVG in a custom field will make your images look large and they would exceed a proportional height value. To fix this issue, all you need to do is simply add the below mentioned code snippet to your WordPress theme’s functions.php file:
<?php
function wp_svg_style() {
echo ‘<style>
svg, img[src*=”.svg”] {
width: 120px;
height: 120px;
}
</style>';
}
add_action('admin_head', 'wp_svg_style');
?>
If you look at the above code carefully, you’ll find that I’ve added a small CSS declaration into the WP dashboard page. That means each time the selector finds <svg> elements along with .svg images, it will override default height and width attributes(i.e. 1px × 1px as set in WordPress editor, with no limits in the custom field) and also go ahead with adjusting the attributes to a box with dimensions 120px × 120px.
Do remember that the above step must be performed only under a scenario wherein you’re making your SVGs look better via a simple tool that helps in eliminating height and width attributes. Hence, while the tool eliminates the image attributes, you can go ahead with using CSS for managing the size of these SVGs.
Conclusion
In today’s retina-ready web world, equipping your website with SVGs is indeed an intelligent decision. Uploading and using SVG on your WordPress website is a practice that will help drive maximum traffic towards your web portal and people will love exploring your site to the fullest.
Author Biography
Amanda is currently working for Xicom Technologies Ltd- a renowned iPhone app development company. She has been an avid IT personnal with special interest in writing posts that serve as handy guide for individuals looking out to build a strong career in IT services and solutions sector.
Amazing article! I like the way you write.
Wonderful article. I need to bookmark this site right away.
Thank you Sir.
Being new to the blogging world I feel like there is still so much to learn. Your tips helped to clarify a few things for me as well as giving..
thanks for this
Wonderful tutorial thanks to share
Thanks for sharing such a tips on usage of wordpress websites.
Scalable Vector Graphics SVG I was not aware of this but a really good write-up on this topic and making us aware of the same. BTW which theme is this looking cool….like you
svg looks great..
amazing article I appreciate you sharing this article
Nice information moslty users are looking for the info on google so here i suggested you keep updates dialy to get followers
great post and information. Thanks to you buddy.
Most satisfied tutorials available on internet for the current topic. I am a regular user of WordPress website. And also admit of of different website. I know very well uses of SVG and WordPress.
Thanks for sharing useful information
Keep sharing new things to here mate. i m just refreshing it
Thanks for the information
Thank Guys.
Thank you For Posting On WordPress. I Need it
Thank you for Posting . cheers
this is nice.
Thanks for the information
Awesome news..
SVGs look better via a simple tool that helps in eliminating height and width attributes. Hence, while the tool eliminates the image attributes, you can go ahead with using CSS for managing the size of these SVGs.
hi nice post and great information shared
Hi,
Danke für den informativen Artikel. Fehlen dabei tun mir aber einige Beispielwebsites, welche die SVG-Integration in WordPress auch implementiert haben.
Awesome post. Thanks. Govt Jobs
this is awesome.
wow article thanks for sharing with us.
awesome information in this post thanks for sharing with us.
nice post and great information shared
information shared to us is great
Nice Information in the post
Awesome Information in the post
Amazing Information in the post
Great Jobs website, I just checked this one.