Articles of svg

use of <svg> tag into wordpress

Hi i’m trying to upload a svg map to my wordpress website. I fixed all to be able to upload svg trough the media gallery but then when i try to write the tag into the page it won’t recognize it. I can only use it embedding it into a tag… but i can’t do […]

Allow SVG in WP step by step

I’m not strong in WP programming, bu I try to understand what to do to enable SVG in my site. I found that in need to add function below to functions.php: /** * Add SVG capabilities */ function wpcontent_svg_mime_type( $mimes = array() ) { $mimes[‘svg’] = ‘image/svg+xml’; $mimes[‘svgz’] = ‘image/svg+xml’; return $mimes; } add_filter( ‘upload_mimes’, […]

Querying a large number of posts including their custom fields data

I’m building a SVG map separated into about 200 regions. For each region there are attributes that describe it, as well as a region ID. These regions are just polygons in the SVG. I setup a custom post type so that the data associated with these regions could be added in the dashboard, and upon […]

Disable automatig SVG tag from menu

I’m using twentyseventeen theme as base to design my own, but when i use wp_nav_menu to print menus, it adds some unwanted svg elements which break my design. Elements are like: <svg class=”icon icon-angle-down” aria-hidden=”true” role=”img”> <use href=”#icon-angle-down” xlink:href=”#icon-angle-down”></use> </svg> How can i disable this?

How do I enable the customize theme page to accept svg's?

I’m currently working on a theme that enables the user to upload a logo via the customize theme page. I want the user to be able to upload an SVG as a logo. WordPress does not allow SVG’s to be uploaded by default. So I used a snippet of code to enable SVG’s in de […]

Stylizing external SVG files with jQuery and CSS

I have enabled SVG-file-linking on my WP site using the Safe SVG plug-in, and I’m mostly happy with it. However, I’m having an issue with styling the SVG-paths contained in the external-file I am calling/linikng. Currently, I am unable to create the interactivitiy I desire because I cannot: use my custom javascript/jQuery to add classes […]

How to Include SVG sprites icons into the body tag?

I want to include an SVG icon file after the body tag and I’m using this code: <?php include_once(“assets/img/sprites.svg”); ?> But I get this error: Parse error: syntax error, unexpected T_STRING in /home/ostadba1/public_html/wp-content/themes/ostad/assets/img/sprites.svg on line 1 the purpose for this is that I want use those icons with one line of code: <svg class=”icon”><use xlink:href=”#shopping-cart”></use></svg> […]

Understanding SVG vulnerabilities in WordPress related to a specific fix

I have enabled SVG uploading for my WordPress logo using the answer provided on this stack link, despite having read, in numerous places, that SVG support in a WordPress site opens it up to scripting attacks. Here is just one such source: For what security reasons are svgs blocked in the media uploader? My question […]

Set media metadata (i.e. “dimensions” field) on SVG file after extracting it with a filter

My question is about how to attached the size dimensions I have successfully extracted from an SVG and force them into the WP ‘dimensions’ field associated with the file, so that the dimensions appear in the media library. Note: this is not the same as this earlier question I posted. In that question, I asked […]

How to use a svg as custom header?

I want to use a svg as a custom header in WordPress. I tried two ways: First I want the user to be able to upload their own svg as a custom header. So I enabled svg uploads in the functions.php: function cc_mime_types($mimes) { $mimes[‘svg’] = ‘image/svg+xml’; return $mimes; } add_filter(‘upload_mimes’, ‘cc_mime_types’); But that does […]