Articles of svg

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 […]

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!

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 reasons this file is not allowed” – I’m stumped on what to check next to try and debug it.

Cant upload SVG files after updating WordPress 4.7.1

This question already has an answer here: SVG files not uploading since most recent WP update 3 answers

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 my theme’s functions.php file /*** enable svg support ***/ function cc_mime_types($mimes) { $mimes[‘svg’] = ‘image/svg+xml’; return $mimes; } add_filter(‘upload_mimes’, ‘cc_mime_types’); Then […]

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 related to the width of the SVGs being returned as zero by wp_get_attachment_image_src(). So what I am I trying to […]