{"id":2206,"date":"2021-06-09T12:58:24","date_gmt":"2021-06-09T04:58:24","guid":{"rendered":"https:\/\/www.intelliwolf.com\/?p=2206"},"modified":"2021-06-09T12:58:27","modified_gmt":"2021-06-09T04:58:27","slug":"allow-admins-upload-svg-to-wordpress","status":"publish","type":"post","link":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/allow-admins-upload-svg-to-wordpress\/","title":{"rendered":"How To Allow Admins To Upload SVG To WordPress"},"content":{"rendered":"\n

Scalable Vector Graphics (\"SVG\") can be a great way to display line art on your site at a range of sizes without having to worry about file sizes.<\/p>\n\n\n\n

They're particularly useful for a logo or for social media icons.<\/p>\n\n\n\n

However, due to the way they're coded, uploading an infected SVG can be a potential security risk, which is why WordPress doesn't allow you to upload them by default.<\/p>\n\n\n\n

You might see something like this if you try to upload them in the usual way:<\/p>\n\n\n\n

\"screenshot<\/figure><\/div>\n\n\n\n

The potential security flaw comes from uploading a file from a malicious user, or from allowing a malicious user to upload them.<\/p>\n\n\n\n

If you've created the SVG yourself and you're the admin of the site, you should be allowed to easily upload an SVG file.<\/p>\n\n\n\n

At the same time, we probably only want to allow admins to upload SVGs.<\/p>\n\n\n\n

To allow administrators to upload SVG files to WordPress, add the following code to your function.php<\/em> file:<\/p>\n\n\n\n

add_filter( 'upload_mimes', 'iw_add_svg_mime' );\nfunction iw_add_svg_mime( $mimes ) {\n  if ( !current_user_can( 'edit_theme_options' ) ) {\n    return $mimes;\n  }\n  $mimes['svg'] = 'image\/svg+xml';\n  return $mimes;\n}<\/code><\/pre>\n\n\n\n

This code hooks into the \"upload_mimes\" filter. If the user isn't an administrator, it just returns the normal list of allowed file types.<\/p>\n\n\n\n

Otherwise, the code adds SVG to the allowed file times and returns the list for the uploader to process.<\/p>\n\n\n\n

If you're only going to be uploading SVGs during the design process, you might want to add this initially, then remove it when the site goes live.<\/p>\n\n\n\n

There's no need to remove it if you're going to continue to use it. It's just best to remove code that's no longer being utilised.<\/p>\n\n\n\n

WordPress doesn't stop you using SVGs, it's just trying to protect the unwary user from uploading a bad one.<\/p>\n","protected":false},"excerpt":{"rendered":"

Scalable Vector Graphics (“SVG”) can be a great way to display line art on your site at a range of sizes without having to worry about file sizes. They’re particularly useful for a logo or for social media icons. However, due to the way they’re coded, uploading an infected SVG can be a potential security<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"yoast_head":"\nHow To Allow Admins To Upload SVG To WordPress<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Allow Admins To Upload SVG To WordPress\" \/>\n<meta property=\"og:description\" content=\"Scalable Vector Graphics ("SVG") can be a great way to display line art on your site at a range of sizes without having to worry about file sizes. They're particularly useful for a logo or for social media icons. However, due to the way they're coded, uploading an infected SVG can be a potential security\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/\" \/>\n<meta property=\"og:site_name\" content=\"Intelliwolf\" \/>\n<meta property=\"article:published_time\" content=\"2021-06-09T04:58:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-06-09T04:58:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/intelliwolf.com\/wp-content\/uploads\/2021\/06\/2021-06-09-upload-svg-to-wp.png\" \/>\n<meta name=\"author\" content=\"Mike Haydon\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mike Haydon\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/\"},\"author\":{\"name\":\"Mike Haydon\",\"@id\":\"https:\/\/www.intelliwolf.com\/#\/schema\/person\/7209e3ff14822e4d70d5f194a310f343\"},\"headline\":\"How To Allow Admins To Upload SVG To WordPress\",\"datePublished\":\"2021-06-09T04:58:24+00:00\",\"dateModified\":\"2021-06-09T04:58:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/\"},\"wordCount\":284,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.intelliwolf.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/intelliwolf.com\/wp-content\/uploads\/2021\/06\/2021-06-09-upload-svg-to-wp.png\",\"articleSection\":[\"Admin Customization\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/\",\"url\":\"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/\",\"name\":\"How To Allow Admins To Upload SVG To WordPress\",\"isPartOf\":{\"@id\":\"https:\/\/www.intelliwolf.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/intelliwolf.com\/wp-content\/uploads\/2021\/06\/2021-06-09-upload-svg-to-wp.png\",\"datePublished\":\"2021-06-09T04:58:24+00:00\",\"dateModified\":\"2021-06-09T04:58:27+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/#primaryimage\",\"url\":\"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/2021\/06\/2021-06-09-upload-svg-to-wp.png\",\"contentUrl\":\"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/2021\/06\/2021-06-09-upload-svg-to-wp.png\",\"width\":294,\"height\":170},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.intelliwolf.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Admin Customization\",\"item\":\"https:\/\/www.intelliwolf.com\/category\/admin-customization\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How To Allow Admins To Upload SVG To WordPress\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.intelliwolf.com\/#website\",\"url\":\"https:\/\/www.intelliwolf.com\/\",\"name\":\"Intelliwolf\",\"description\":\"WordPress, Web Design and Coding Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.intelliwolf.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.intelliwolf.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.intelliwolf.com\/#organization\",\"name\":\"Intelliwolf\",\"url\":\"https:\/\/www.intelliwolf.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.intelliwolf.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/intelliwolf-logo-300t.png\",\"contentUrl\":\"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/intelliwolf-logo-300t.png\",\"width\":300,\"height\":100,\"caption\":\"Intelliwolf\"},\"image\":{\"@id\":\"https:\/\/www.intelliwolf.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.intelliwolf.com\/#\/schema\/person\/7209e3ff14822e4d70d5f194a310f343\",\"name\":\"Mike Haydon\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.intelliwolf.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d5f4754fae310a04dede91d15e57c8a0?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d5f4754fae310a04dede91d15e57c8a0?s=96&d=mm&r=g\",\"caption\":\"Mike Haydon\"},\"sameAs\":[\"https:\/\/intelliwolf.com\/about-mike-haydon\/\"]}]}<\/script>\n","yoast_head_json":{"title":"How To Allow Admins To Upload SVG To WordPress","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/","og_locale":"en_US","og_type":"article","og_title":"How To Allow Admins To Upload SVG To WordPress","og_description":"Scalable Vector Graphics (\"SVG\") can be a great way to display line art on your site at a range of sizes without having to worry about file sizes. They're particularly useful for a logo or for social media icons. However, due to the way they're coded, uploading an infected SVG can be a potential security","og_url":"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/","og_site_name":"Intelliwolf","article_published_time":"2021-06-09T04:58:24+00:00","article_modified_time":"2021-06-09T04:58:27+00:00","og_image":[{"url":"https:\/\/intelliwolf.com\/wp-content\/uploads\/2021\/06\/2021-06-09-upload-svg-to-wp.png"}],"author":"Mike Haydon","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Mike Haydon","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/#article","isPartOf":{"@id":"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/"},"author":{"name":"Mike Haydon","@id":"https:\/\/www.intelliwolf.com\/#\/schema\/person\/7209e3ff14822e4d70d5f194a310f343"},"headline":"How To Allow Admins To Upload SVG To WordPress","datePublished":"2021-06-09T04:58:24+00:00","dateModified":"2021-06-09T04:58:27+00:00","mainEntityOfPage":{"@id":"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/"},"wordCount":284,"commentCount":0,"publisher":{"@id":"https:\/\/www.intelliwolf.com\/#organization"},"image":{"@id":"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/#primaryimage"},"thumbnailUrl":"https:\/\/intelliwolf.com\/wp-content\/uploads\/2021\/06\/2021-06-09-upload-svg-to-wp.png","articleSection":["Admin Customization"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/","url":"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/","name":"How To Allow Admins To Upload SVG To WordPress","isPartOf":{"@id":"https:\/\/www.intelliwolf.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/#primaryimage"},"image":{"@id":"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/#primaryimage"},"thumbnailUrl":"https:\/\/intelliwolf.com\/wp-content\/uploads\/2021\/06\/2021-06-09-upload-svg-to-wp.png","datePublished":"2021-06-09T04:58:24+00:00","dateModified":"2021-06-09T04:58:27+00:00","breadcrumb":{"@id":"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/#primaryimage","url":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/2021\/06\/2021-06-09-upload-svg-to-wp.png","contentUrl":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/2021\/06\/2021-06-09-upload-svg-to-wp.png","width":294,"height":170},{"@type":"BreadcrumbList","@id":"https:\/\/www.intelliwolf.com\/allow-admins-upload-svg-to-wordpress\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.intelliwolf.com\/"},{"@type":"ListItem","position":2,"name":"Admin Customization","item":"https:\/\/www.intelliwolf.com\/category\/admin-customization\/"},{"@type":"ListItem","position":3,"name":"How To Allow Admins To Upload SVG To WordPress"}]},{"@type":"WebSite","@id":"https:\/\/www.intelliwolf.com\/#website","url":"https:\/\/www.intelliwolf.com\/","name":"Intelliwolf","description":"WordPress, Web Design and Coding Tutorials","publisher":{"@id":"https:\/\/www.intelliwolf.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.intelliwolf.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.intelliwolf.com\/#organization","name":"Intelliwolf","url":"https:\/\/www.intelliwolf.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.intelliwolf.com\/#\/schema\/logo\/image\/","url":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/intelliwolf-logo-300t.png","contentUrl":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-content\/uploads\/intelliwolf-logo-300t.png","width":300,"height":100,"caption":"Intelliwolf"},"image":{"@id":"https:\/\/www.intelliwolf.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.intelliwolf.com\/#\/schema\/person\/7209e3ff14822e4d70d5f194a310f343","name":"Mike Haydon","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.intelliwolf.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d5f4754fae310a04dede91d15e57c8a0?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d5f4754fae310a04dede91d15e57c8a0?s=96&d=mm&r=g","caption":"Mike Haydon"},"sameAs":["https:\/\/intelliwolf.com\/about-mike-haydon\/"]}]}},"_links":{"self":[{"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/posts\/2206"}],"collection":[{"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/comments?post=2206"}],"version-history":[{"count":2,"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/posts\/2206\/revisions"}],"predecessor-version":[{"id":2214,"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/posts\/2206\/revisions\/2214"}],"wp:attachment":[{"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/media?parent=2206"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/categories?post=2206"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress-757293-2559390.cloudwaysapps.com\/wp-json\/wp\/v2\/tags?post=2206"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}