Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

Questions tagged [svg]

The tag has no usage guidance.

-2
votes
0answers
7 views

Fill svg with thumbnail [on hold]

I try to fill an SVG with an image using pattern, like that : <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 370.75 318.57" preserveAspectRatio="xMinYMin meet"> <defs> &...
0
votes
1answer
25 views

Are SVG image files safe to upload? Why WP defines them as a security risk? [duplicate]

I'd like to upload a map of the USA in a SVG format however I am prevented from doing so because of a 'security risk'. Any ideas why this is? Is it safe to do so? Thanks
1
vote
1answer
43 views

Adding extra SVGs to TwentyNineteen child theme using class TwentyNineteen_SVG_Icons

I’m trying to change the svg of the ellipses for the mobile menu. It’s called in this file: template-functions.php so I did a hook on my child theme functions.php to replace it, like so: function ...
0
votes
0answers
11 views

Add a svg and show some text on the parts of that view when the user hover or click on that part in WordPress

I am working in my WordPress website and I want to add a svg to my website and show some text on the parts of that view when the user hover or click on that part in WordPress. I have searched a lot ...
0
votes
1answer
18 views

Replace Home with image link inside custom header menu

What I want to achieve is a header menu like this: Right now, I have this: I am not far off. To get to where I am currently at, I followed these instructions and added some custom CSS. So I added ...
2
votes
1answer
44 views

getting uploaded SVG dimensions on front-end

Having successfully uploaded an SVG image through WordPress's back-end media uploader with the help of a third party plugin such as Safe SVG by Daryll Doyle, how can one get the image's dimensions ...
0
votes
1answer
50 views

Wordpress search form and input type=“image”

I need help with this code. How can I get the search field to display when clicking on the search-icon.svg? <form role="search" method="get" class="search-form" action="<?php echo home_url( '/...
2
votes
2answers
2k views

How to upload SVG in WordPress 4.9.8?

I tried uploading after installing different plugins. Even added a filter to functions.php file. function add_svg_to_upload_mimes( $upload_mimes ) { $upload_mimes['svg'] = 'image/svg+xml'; ...
0
votes
1answer
251 views

Enable CORS for getting an inline SVG by URL

TLDR; Is there a way I can enable CORS for SVGs in my WordPress back-end, so I can get them through a http request to a different domain? Ideally without having to touch .htaccess? What I'm aiming ...
1
vote
1answer
241 views

Escaping SVG with KSES

I'm trying to output an SVG file in a template, and PHPCS is telling me I need to escape the output. So I tried with KSES and it doesn't seem to want to include the viewbox attribute. $allowed_html =...
3
votes
1answer
166 views

Tiny MCE editor stripping xlink:href parameter from SVG USE tag

I have an inline SVG tag with an embedded <USE> tag. HTML: <ul> <li><svg class="icon-user"><use xlink:href="#icon-user"></use></svg> My Account</li>...
0
votes
1answer
2k views

Can you change the color of svg icons to the global color I choose from Wordpress

For example If I make svg icons that are grey and violet, when I change the global color scheme on wordpress, Is it possible to make it work so if the main color scheme was violet, and I change the ...
0
votes
2answers
516 views

How to implement my own icons instead of using the svg icon system

From WordPress 4.9.2, I created a child theme for twentyseventeen. I noticed that it comes with its own SVG icon system for social media icons at the bottom of the page. I see some of that code ...
1
vote
2answers
995 views

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 ...
5
votes
0answers
118 views

Escaping and sanitizing SVGs in metabox textarea

I want to include inline SVGs in a metabox textarea. That's easy. What's killing me is how do I sanitize the textarea before saving the postmeta, and how do I escape it? Halp? Thanks!
4
votes
2answers
3k views

How to Include SVG sprites icons into the body tag? [closed]

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 ...
2
votes
1answer
552 views

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 ...
8
votes
2answers
2k views

Can't extract and set SVG dimensions

Up to now, I have had no problems with the background-image thumbnails in my theme. However, now that I'm trying to use an SVG as the featured image, something is breaking. The problem seems to ...
3
votes
2answers
2k views

SVG image upload stopped working

I have a client website that has the mime type support for SVG's added in the functions file. We've been uploading svg's for over a year. Suddenly it stopped working and is showing the "for security ...
4
votes
2answers
5k views

Cant upload SVG files after updating Wordpress 4.7.1 [duplicate]

I updated Wordpress to 4.7.1 and cant upload SVG anymore. I had a function in my functions.php file function cc_mime_types($mimes) { $mimes['svg'] = 'image/svg+xml'; return $mimes; } ...
17
votes
3answers
2k views

SVG files not uploading since most recent WP update

I have a snippet in my functions PHP file that allows me to upload SVG files. Since upgrading to the latest version of WP today, I can no longer upload svgs. I also tried a second code snippet from ...
0
votes
3answers
443 views

How to delay display of page elements until enqueued script has injected html

I am enqueuing some javascript that injects SVGs into my page's DOM (called SVGInjector); it works great except for one thing: there is an undesirable "blink"/shift of elements on my screen where the ...
1
vote
2answers
2k views

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 ...
4
votes
2answers
3k views

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 ...
6
votes
1answer
1k views

Issue with wp_get_attachment_image() and SVG file type

I'm trying to use SVG image with wp_get_attachment_image() but it is generating very weird output at the front end of the website. To support SVG file type I've first added the following function in ...
2
votes
2answers
4k views

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: ...
0
votes
2answers
1k views

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 ...
0
votes
1answer
44 views

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 ...
14
votes
1answer
1k views

For what security reasons are svgs blocked in the media uploader?

I see that SVGs are blocked by default in the media uploader and you have to add it as a supported MIME type in functions.php. What security reasons are behind this?
1
vote
1answer
3k views

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 ...
2
votes
1answer
2k views

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 ...
9
votes
3answers
3k views

Ways to handle SVG rendering in wordpress?

With the advancement of internet browsers, I find myself more and more comfortable using SVGS when coding websites... especially for icons, and simple graphics that can be replaced on the fly by pngs. ...