U4-6008 - 7.2 Adding SVG to imageFileTypes list in umbracoSettings.config causes error on upload.

Created by Chris Percival 12 Dec 2014, 15:12:09 Updated by Nicholas Westby 04 Sep 2018, 22:42:40

Relates to: U4-7189

After adding SVG to imageFileTypes list in umbracoSettings.config adding an SVG image to the media library by draging it in or clicking upload fails silently. If I upload a jpg (for example) then try to change it to and SVG I get the following error:

System.ArgumentException: Parameter is not valid. at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData) at Umbraco.Web.PropertyEditors.FileUploadPropertyValueEditor.ConvertEditorToDb(ContentPropertyData editorValue, Object currentValue) at Umbraco.Web.Editors.ContentControllerBase.MapPropertyValues[TPersisted](ContentBaseItemSave1 contentItem) at Umbraco.Web.Editors.MediaController.PostSave(MediaItemSave contentItem) at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments) at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func1 func, CancellationToken cancellationToken)

1 Attachments


Chris Percival 16 Dec 2014, 15:01:20

This error is caused by having svg in the imageFileTypes list in umbracoSettings.config, causing umbraco to try to create a thumbnail. Umbraco should still be able to deal with this though.

Lindsay Avery 11 May 2015, 15:43:14

Also an issue in 7.2.4. SVG doesn't conform to System.Drawing.Image so when it tries to create the thumbnail it throws an error.

Jordan Lane 13 May 2016, 14:28:13

I've created a pull request that fixes it here: https://github.com/umbraco/Umbraco-CMS/pull/1267

Anders Brohäll 01 Jun 2016, 08:38:26

Affects only uploads from RTE's? You can upload directly into the Media section. Pheeew.

Asbjørn Riis-Knudsen 01 Jun 2016, 09:17:03

@anders No, it affects every media picker, IF you have added svg to the imageFileTypes setting. Umbraco looks at this setting to determine whether it should create a thumbnail. If SVG is on this list, it will attempt to use System.Drawing to create a thumbnail - which of course fails.

Alex Lindgren 16 Sep 2016, 15:53:50

I am also getting this error. If you don't add the svg to the imageFileTypes list (and have removed it from disallowedUploadFiles), then you can upload it (treated as a file) but thumbnails don't work. But after uploading it, and then you add svg to the imageFileTypes list, thumbnails will work (but you can't then upload more). I imagine this has not been fixed because it is easy to work around, I really hope SVGs are given first-class treatment in Umbraco media soon.

Catherine Stevens 13 Nov 2017, 23:23:16

I am getting this error too, version 7.5.3.

If I include this piece of code in {{umbracoSettings.config}}:

    <!-- what file extension that should cause umbraco to create thumbnails -->

I get the error the original poster said (when I upload SVGs to the media section). If I remove it then I can upload an SVG. But then I can't choose the image in a RTE. I can only pick it in the Media Picker datatype.

Throughout all this, I have {{svg}} removed from the {{disallowedUploadFiles}} flag in {{umbracoSettings.config}}.

Nicholas Westby 27 Apr 2018, 17:56:25

This issue still exists on Umbraco 7.10.4. I added some info to the pull request, which seems to have been reopened now.

Brian Lee 07 Jun 2018, 23:45:56

First of all, Happy Belated Birthday [U4-6008]! You're almost at an adorable pre-school age. Can't wait for your first day of school. Share pics!!

So Google started indexing SVGs around the year 2010. It's 8 years later and ~4 years into this ticket. There's legitimacy in saying this issue ought to be knocked out sooner than later.

Alan Mac Kenna 12 Jul 2018, 18:03:47

I really hopes this makes it in soon!

Markus Johansson 29 Aug 2018, 13:45:52

@sebastiaan This is quite a simple one to solve, right? There is already a PR that just catches the exception from the image parsing-code, I do agree with the comments on the PR but I still think that it's worth adding this as a workaround until other solutions are figured out. Link to PR: https://github.com/umbraco/Umbraco-CMS/pull/1267

Nicholas Westby 04 Sep 2018, 22:42:40

I have moved this over to the new issue tracker: https://github.com/umbraco/Umbraco-CMS/issues/2909

Per the recent blog post about migrating issues.

Priority: Normal

Type: Bug

State: Submitted


Difficulty: Normal


Backwards Compatible: True

Fix Submitted: Pull request

Affected versions: 7.2.0, 7.3.0, 7.7.4, 7.10.4, 7.11.2

Due in version:


Story Points: